Struct crossbeam_deque::deque::Buffer
source · struct Buffer<T> {
ptr: *mut T,
cap: usize,
}
Expand description
A buffer that holds tasks in a worker queue.
This is just a pointer to the buffer and its length - dropping an instance of this struct will not deallocate the buffer.
Fields§
§ptr: *mut T
Pointer to the allocated memory.
cap: usize
Capacity of the buffer. Always a power of two.
Implementations§
source§impl<T> Buffer<T>
impl<T> Buffer<T>
sourceunsafe fn at(&self, index: isize) -> *mut T
unsafe fn at(&self, index: isize) -> *mut T
Returns a pointer to the task at the specified index
.
sourceunsafe fn write(&self, index: isize, task: MaybeUninit<T>)
unsafe fn write(&self, index: isize, task: MaybeUninit<T>)
Writes task
into the specified index
.
This method might be concurrently called with another read
at the same index, which is
technically speaking a data race and therefore UB. We should use an atomic store here, but
that would be more expensive and difficult to implement generically for all types T
.
Hence, as a hack, we use a volatile write instead.
sourceunsafe fn read(&self, index: isize) -> MaybeUninit<T>
unsafe fn read(&self, index: isize) -> MaybeUninit<T>
Reads a task from the specified index
.
This method might be concurrently called with another write
at the same index, which is
technically speaking a data race and therefore UB. We should use an atomic load here, but
that would be more expensive and difficult to implement generically for all types T
.
Hence, as a hack, we use a volatile load instead.
Trait Implementations§
impl<T> Copy for Buffer<T>
impl<T> Send for Buffer<T>
Auto Trait Implementations§
impl<T> Freeze for Buffer<T>
impl<T> RefUnwindSafe for Buffer<T>where
T: RefUnwindSafe,
impl<T> !Sync for Buffer<T>
impl<T> Unpin for Buffer<T>
impl<T> UnwindSafe for Buffer<T>where
T: RefUnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)