[][src]Struct redox_buffer_pool::BufferPool

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

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

Implementations

impl<I, H, E> BufferPool<I, H, E> where
    I: Integer,
    H: Handle<I, E>,
    E: Copy
[src]

#[must_use = "calling begin_expand alone only reserves a range; you need to allocate some actually memory, using the handle"]pub fn begin_expand(
    &self,
    additional: I
) -> Result<ExpansionHandle<I, H, E>, BeginExpandError>
[src]

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.

pub fn handle(&self) -> Option<&H>[src]

Retrieve the user "handle" that was passed to this buffer pool at initialization.

pub fn try_close(self) -> CloseResult<I, H, E>[src]

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.

pub fn new(handle: Option<H>) -> Self[src]

Create a new empty buffer pool, using an optional user "handle" that is stored together with the rest of the pool.

pub fn with_options(self, options: BufferPoolOptions<I>) -> Self[src]

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: Guard
[src]

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: Guard,
    C: AsBufferPool<I, H, E>, 
[src]

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: Guard,
    C: AsBufferPool<I, H, E>, 
[src]

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.

pub fn active_guard_count(&self) -> usize[src]

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
[src]

impl<I: Debug, H: Debug, E: Debug> Debug for BufferPool<I, H, E> where
    I: Integer,
    H: Handle<I, E>,
    E: Copy
[src]

impl<I: Integer, H: Handle<I, E>, E: Copy> Drop for BufferPool<I, H, E>[src]

impl<I, H, E> Send for BufferPool<I, H, E> where
    I: Integer + Send,
    H: Handle<I, E> + Send,
    E: Copy + Send
[src]

impl<I, H, E> Sync for BufferPool<I, H, E> where
    I: Integer + Sync,
    H: Handle<I, E> + Sync,
    E: Copy + Sync
[src]

Auto Trait Implementations

impl<I, H, E> !RefUnwindSafe for BufferPool<I, H, E>

impl<I, H, E> Unpin for BufferPool<I, H, E> where
    E: Unpin,
    H: Unpin,
    I: Unpin

impl<I, H, E> !UnwindSafe for BufferPool<I, H, E>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T, I, H, E> AsBufferPool<I, H, E> for T where
    E: Copy,
    H: Handle<I, E>,
    I: Integer,
    T: AsRef<BufferPool<I, H, E>>, 
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.