package uring
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=30ad45e6d4dbbd94f9324c99af3dbcfa78f8f98a3c5717710810c782151d3186
sha512=0f101c1a68f8de1f4d05614d1284beb0755cffa82605c48df6e9b7a336249f614d0eb46f9626063ac96fca5345b248abf4cb193a9d00047bd1edb3c1aa714c7c
doc/uring/Uring/Region/index.html
Module Uring.RegionSource
Region handles carving up a block of external memory into smaller chunks. This is currently just a slab allocator of a fixed size, on the basis that most IO operations operate on predictable chunks of memory. Since the block of memory in a region is contiguous, it can be used in Uring's fixed buffer model to map it into kernel space for more efficient IO.
t is a contiguous region of memory
chunk is an offset into a region of memory allocated from some region t. It is of a length set when the region t associated with it was initialised.
No_space is raised when an allocation request cannot be satisfied.
init ~block_size buf initialises a region from the buffer buf, carving it into length(buf) / block_size chunks of block_size bytes each. Any trailing bytes that do not fill a whole chunk are unused.
alloc t will allocate a single chuck of length block_size from the region t.
free chunk will return the memory chunk back to the region t where it can be reallocated.
to_offset chunk will convert the chunk into an integer offset in its associated region. This can be used in IO calls involving that memory.
to_cstruct chunk is a cstruct of chunk's slice of the region. Note that this is a zero-copy view into the underlying region t and so chunk should not be freed until this cstruct is no longer used.
to_bigstring is like to_cstruct, but creates a Bigarray. Note that this is a zero-copy view into the underlying region t and so chunk should not be freed until this Bigarray reference is no longer used.
to_string ?len chunk will return a copy of chunk as an OCaml string.