Crate redox_buffer_pool[][src]

Expand description


This crate provides a buffer pool for general-purpose memory management, with support for allocating slices within the pool, as well as expanding the pool with potentially non-adjacent larger underlying memory allocations, like mmap(2) or other larger possible page-sized allocations.

The current allocator uses one B-trees to partition the space into regions either marked as occupied or free. The keys used by the B-tree have a custom comparator, which ensures that keys for used ranges are orderered after the keys for free ranges. This, together with having a free space tree, makes acquiring buffer slices possible in O(log n), provided that there is already an aligned range (otherwise, it simply does linear search in O(n) until it finds a range large enough to account for the misalignment).



Markers for whether the buffer pool will use guards, or not.



The error internally caused by arithmetic overflow, that indicates the buffer pool has no more usable ranges.


A buffer pool, featuring a general-purpose 32-bit allocator, and slice guards.


Various options used by the buffer pool mainly to limit the range of possible sizes and alignments.


A slice from the buffer pool, that can be read from or written to as a regular smart pointer.


The error from BufferPool::try_close, meaning that there is currently a guarded buffer slice in use by the pool, preventing resource freeing.


A handle for expansion. When this handle is retrieved by the BufferPool::begin_expand method, the range has already been reserved, so it’s up to this handle to initialize it.


The iterator given to the close handle, or optionally retrieved by manually destroying a buffer pool, that contains all the underlying allocations that the pool has been expanded with.


The entry type from the MmapEntries iterator, that contains all the information that the buffer pool had about that mmap, when it’s being destroyed.


The potential error from [BufferSlice::reclaim], caused by the slice being guarded.


The potential error from [BufferSlice::with_guard] or [BufferSlice::guard], indicating that a different guard is already in use by the the buffer slice. Since that method takes self by value, the old self is included here, to allow for reuse in case of failure.



The strategy to use when allocating, with tradeoffs between heap fragmentation, and the algorithmic complexity of allocating.


A handle type that cannot be initialized, causing the handle to take up no space in the buffer pool struct.



A trait for types that are convertible by reference, into BufferPool.


A trait for pointer types that uphold the guard invariants, namely that the pointer must be owned, and that it must dereference into a stable address.


A trait for pointer types that uphold the guard invariants, and are able to dereference mutably.


The requirement of a handle to be able to be passed into the buffer pool.


A type that can be used as offsets and lengths within a buffer pool. The default integer is u32.


An unsafe marker trait for types that deref to a stable address, even when moved. For example, this is implemented by Box, Vec, Rc, Arc and String, among others. Even when a Box is moved, the underlying storage remains at a fixed location.

Type Definitions


The result originating from BufferPool::try_close.