Struct redox_buffer_pool::BufferPool [−][src]
Expand description
A buffer pool, featuring a general-purpose 32-bit allocator, and slice guards.
Implementations
pub fn begin_expand(
&self,
additional: I
) -> Result<ExpansionHandle<'_, I, H, E>, BeginExpandError>
pub fn begin_expand(
&self,
additional: I
) -> Result<ExpansionHandle<'_, I, H, E>, BeginExpandError>
Begin a buffer pool expansion, by reserving a new not-yet-usable “pending” mmap region.
Internally, this will use an intent lock, so while there can be multiple parallel expansions in the actual allocation phase, the process of finding a new range within the pool for allocation, can only have one writer at a time. That said, readers of this pool will still be able to function correctly, and the only critical exclusive section, is only to insert the new range into the pool.
Note that this type will only give a handle to the reserved range, that will lazily initialize it. This method will only reserve a range.
Panics
This method will panic if the size inputted, is zero.
Retrieve the user “handle” that was passed to this buffer pool at initialization.
Attempt to close, and thus free each buffer slice owned by the entire pool, returning the handle and the mmap ranges if present.
If there are any pending commands that have guarded buffer slices from this pool, the entire memory will be leaked, for now.
Create a new empty buffer pool, using an optional user “handle” that is stored together with the rest of the pool.
Set the allocation options used by the buffer pool, e.g. the size and alignment bounds.
pub fn acquire_borrowed_slice<G>(
&self,
len: I,
alignment: I,
strategy: AllocationStrategy<I>
) -> Option<BufferSlice<'_, I, H, E, G>> where
G: Marker,
pub fn acquire_borrowed_slice<G>(
&self,
len: I,
alignment: I,
strategy: AllocationStrategy<I>
) -> Option<BufferSlice<'_, I, H, E, G>> where
G: Marker,
Try to acquire a statically (as in compiler-checked and lifetime-tied) borrowed slice, from this buffer. The slice will automatically be reclaimed upon drop, so long as there is no guard protecting the slice at that time. If there is, the memory will be leaked instead, and the pool will not be able to use the offset, as it will be marked “occpied” and nothing will free it.
pub fn acquire_weak_slice<G, C>(
this: &Arc<C>,
len: I,
alignment: I,
strategy: AllocationStrategy<I>
) -> Option<BufferSlice<'static, I, H, E, G, C>> where
G: Marker,
C: AsBufferPool<I, H, E>,
pub fn acquire_weak_slice<G, C>(
this: &Arc<C>,
len: I,
alignment: I,
strategy: AllocationStrategy<I>
) -> Option<BufferSlice<'static, I, H, E, G, C>> where
G: Marker,
C: AsBufferPool<I, H, E>,
Try to acquire a weakly-borrowed (std::sync::Weak
) slice, that may outlive this buffer
pool. If that would happen, most functionality of the slice would cause it to panic,
although this can be checked for as well.
These slices can also be guarded, see acquire_borrowed_slice
for a detailed explanation
of that.
pub fn acquire_strong_slice<G, C>(
this: &Arc<C>,
len: I,
alignment: I,
strategy: AllocationStrategy<I>
) -> Option<BufferSlice<'static, I, H, E, G, C>> where
G: Marker,
C: AsBufferPool<I, H, E>,
pub fn acquire_strong_slice<G, C>(
this: &Arc<C>,
len: I,
alignment: I,
strategy: AllocationStrategy<I>
) -> Option<BufferSlice<'static, I, H, E, G, C>> where
G: Marker,
C: AsBufferPool<I, H, E>,
Try to acquire a strongly-borrowed (std::sync::Arc
) slice, that ensures this buffer
pool cannot be outlived by preventing the whole pool from being dropped.
These slices can also be guarded, see acquire_borrowed_slice
for a detailed explanation
of that.
Returns the number of active guards that are used in the pool.
This method is O(1) and doesn’t count anything; it simply fetches an internal counter.
Trait Implementations
impl<I, H, E> AsBufferPool<I, H, E> for BufferPool<I, H, E> where
I: Integer,
H: Handle<I, E>,
E: Copy,
impl<I, H, E> AsBufferPool<I, H, E> for BufferPool<I, H, E> where
I: Integer,
H: Handle<I, E>,
E: Copy,
Get a reference to the buffer pool that must be contained within the wrapper.
Auto Trait Implementations
impl<I, H, E> !RefUnwindSafe for BufferPool<I, H, E>
impl<I, H, E> Unpin for BufferPool<I, H, E> where
H: Unpin,
I: Unpin,
impl<I, H, E> !UnwindSafe for BufferPool<I, H, E>