Struct atomic_queue::Queue
source · [−]pub struct Queue<T> { /* private fields */ }Expand description
Atomic queue cloned from https://github.com/max0x7ba/atomic_queue
Should be:
- Lock-free
Any type can be pushed into the queue, but it’s recommended to use some sort of smart pointer that can be free-ed outside of the critical path.
Uses unsafe internally.
Implementations
sourceimpl<T> Queue<T>
impl<T> Queue<T>
sourcepub fn new(capacity: usize) -> Self
pub fn new(capacity: usize) -> Self
Create a queue with a certain capacity. Writes will fail when the queue is full.
sourcepub fn push(&self, element: T) -> bool
pub fn push(&self, element: T) -> bool
Push an element into the queue and return true on success.
false will be returned if the queue is full. If there’s contention this operation will
wait until it’s able to claim a slot in the queue.
sourcepub fn pop(&self) -> Option<T>
pub fn pop(&self) -> Option<T>
Pop an element from the queue and return true on success.
false will be returned if the queue is empty. If there’s contention this operation will
wait until it’s able to claim a slot in the queue.
sourcepub fn force_push(&self, element: T)
pub fn force_push(&self, element: T)
Push an element into the queue without checking if it’s full.
Trait Implementations
Auto Trait Implementations
impl<T> RefUnwindSafe for Queue<T> where
T: RefUnwindSafe,
impl<T> Unpin for Queue<T> where
T: Unpin,
impl<T> UnwindSafe for Queue<T> where
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more