[][src]Struct redox_buffer_pool::BufferPool

pub struct BufferPool<I: Integer, H: Handle, 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,
    E: Copy
[src]

pub fn begin_expand(
    &self,
    additional: I
) -> Result<ExpandHandle<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.

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

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

pub fn close(self) -> Result<Option<H>, CloseError<Self>>[src]

Close an thus free the entire pool. If there are any pending commands that have guarded buffer slices from this pool, the entire memory will be leaked (TODO: Free as much memory as possible when this happens, rather than the entire pool).

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 shared(self) -> Arc<Self>[src]

Convenience wrapper over Arc::new(self).

pub fn acquire_borrowed_slice<G: Guard>(
    &self,
    len: I,
    alignment: I,
    strategy: AllocationStrategy<I>
) -> Option<BufferSlice<I, H, E, G>>
[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: Guard>(
    self: &Arc<Self>,
    len: I,
    alignment: I,
    strategy: AllocationStrategy<I>
) -> Option<BufferSlice<'static, I, H, E, G>>
[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: Guard>(
    self: &Arc<Self>,
    len: I,
    alignment: I,
    strategy: AllocationStrategy<I>
) -> Option<BufferSlice<'static, I, H, E, G>>
[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.

Trait Implementations

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

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

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

impl<I: Integer + Send + Sync, H: Sync + Handle, E: Copy> Sync for BufferPool<I, H, E>[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> where
    E: RefUnwindSafe + UnwindSafe,
    H: UnwindSafe,
    I: RefUnwindSafe + UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[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.