Struct redox_buffer_pool::BufferPool[][src]

pub struct BufferPool<I, H, E> where
    I: Integer,
    H: Handle<I, E>,
    E: Copy
{ /* fields omitted */ }
Expand description

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

Implementations

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.

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.

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.

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

Get a reference to the buffer pool that must be contained within the wrapper.

Formats the value using the given formatter. Read more

Executes the destructor for this type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.