Struct ocl_extras::sub_buffer_pool::SubBufferPool
source · pub struct SubBufferPool<T: OclPrm> { /* private fields */ }
Expand description
A simple (linear search) sub-buffer allocator.
Implementations
sourceimpl<T: OclPrm> SubBufferPool<T>
impl<T: OclPrm> SubBufferPool<T>
sourcepub fn new(len: u32, default_queue: Queue) -> SubBufferPool<T>
pub fn new(len: u32, default_queue: Queue) -> SubBufferPool<T>
Returns a new buffer pool.
sourcepub fn alloc(&mut self, len: u32, flags: Option<MemFlags>) -> Result<usize, ()>
pub fn alloc(&mut self, len: u32, flags: Option<MemFlags>) -> Result<usize, ()>
Allocates space for and creates a new sub-buffer then returns the
buffer id which can be used to ::get
or ::free
it.
sourcepub fn free(&mut self, buffer_id: usize) -> Result<(), usize>
pub fn free(&mut self, buffer_id: usize) -> Result<(), usize>
Deallocates the buffer identified by buffer_id
or returns it back in
the event of a failure.
sourcepub fn get(&self, buffer_id: usize) -> Option<&Buffer<T>>
pub fn get(&self, buffer_id: usize) -> Option<&Buffer<T>>
Returns a reference to the sub-buffer identified by buffer_id
.
sourcepub fn get_mut(&mut self, buffer_id: usize) -> Option<&mut Buffer<T>>
pub fn get_mut(&mut self, buffer_id: usize) -> Option<&mut Buffer<T>>
Returns a mutable reference to the sub-buffer identified by buffer_id
.
sourcepub fn defrag(&mut self)
pub fn defrag(&mut self)
Defragments the buffer. Be sure to ::finish()
any and all command
queues you may be using before doing this.
All kernels with a buffer argument set to any of the sub-buffers in
this pool will need to be created anew or arguments refreshed (use
Kernel::arg_..._named
when initializing arguments in order to change
them later).
Auto Trait Implementations
impl<T> RefUnwindSafe for SubBufferPool<T>where
T: RefUnwindSafe,
impl<T> Send for SubBufferPool<T>
impl<T> Sync for SubBufferPool<T>
impl<T> Unpin for SubBufferPool<T>where
T: Unpin,
impl<T> UnwindSafe for SubBufferPool<T>where
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more