Legend:
Library
Module
Module type
Parameter
Class
Class type
Library
Module
Module type
Parameter
Class
Class type
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.
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.
val init : block_size:int -> Cstruct.buffer -> int -> t
init ~block_size buf slots
initialises a region from the buffer buf
with total size of block_size * slots
.
val free : chunk -> unit
free chunk
will return the memory chunk
back to the region t
where it can be reallocated.
val length : chunk -> int
length chunk
is the block size.
val to_offset : chunk -> int
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.
val to_bigstring : ?len:int -> chunk -> Cstruct.buffer
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.
val to_string : ?len:int -> chunk -> string
to_string ?len chunk
will return a copy of chunk
as an OCaml string.
val avail : t -> int
avail t
is the number of free chunks of memory remaining in the region.