Modulebasement-0.0.16Haskell2010
Basement.UArray.Mutable
A simple array abstraction that allow to use typed array of bytes where the array is pinned in memory to allow easy use with Foreign interfaces, ByteString and always aligned to 64 bytes.
- 1 type
- 20 values
- Packagebasement-0.0.16
- Exports21
- LanguageHaskell2010
- LicenceBSD-3-Clause
- SourceMutable.hs
Property queries
5 declarationsreturn the numbers of elements in a mutable array
Allocation & Copy
9 declarationsCreate a new mutable array of size @n.
When memory for a new array is allocated, we decide if that memory region should be pinned (will not be copied around by GC) or unpinned (can be moved around by GC) depending on its size.
You can change the threshold value used by setting the environment variable
HS_FOUNDATION_UARRAY_UNPINNED_MAX.
Create a new pinned mutable array of size @n.
all the cells are uninitialized and could contains invalid values.
All mutable arrays are allocated on a 64 bits aligned addresses
Same as newNative but expect no extra return value from f
copyAt Copy a number of elements from an array to another array with offsets
Copy from a pointer, count elements, into the mutable array
copyToPtr Copy all the block content to the memory starting at the destination address
Reading and Writing cells
6 declarationswrite to a cell in a mutable array without bounds checking.
Writing with invalid bounds will corrupt memory and your program will
become unreliable. use write if unsure.
read from a cell in a mutable array without bounds checking.
Reading from invalid memory can return unpredictable and invalid values.
use read if unsure.
Write to a cell in a mutable array.
If the index is out of bounds, an error is raised.
read a cell in a mutable array.
If the index is out of bounds, an error is raised.
Create a pointer on the beginning of the mutable array
and call a function f.
The mutable buffer can be mutated by the f function
and the change will be reflected in the mutable array
If the mutable array is unpinned, a trampoline buffer
is created and the data is only copied when f return.