pub struct MpScQueue<T, STO: Storage<T>> {
pub(crate) storage: STO,
pub(crate) dequeue_pos: AtomicUsize,
pub(crate) enqueue_pos: AtomicUsize,
pub(crate) cons_wait: WaitCell,
pub(crate) prod_wait: WaitQueue,
pub(crate) closed: AtomicBool,
pub(crate) pd: PhantomData<T>,
}
Fields§
§storage: STO
§dequeue_pos: AtomicUsize
§enqueue_pos: AtomicUsize
§cons_wait: WaitCell
§prod_wait: WaitQueue
§closed: AtomicBool
§pd: PhantomData<T>
Implementations§
source§impl<T, STO: Storage<T>> MpScQueue<T, STO>
impl<T, STO: Storage<T>> MpScQueue<T, STO>
sourcepub fn new(storage: STO) -> Self
pub fn new(storage: STO) -> Self
Creates an empty queue
The capacity of storage
must be >= 2 and a power of two, or this code will panic.
pub fn close(&self)
sourcepub fn dequeue_sync(&self) -> Option<T>
pub fn dequeue_sync(&self) -> Option<T>
Returns the item in the front of the queue, or None
if the queue is empty
sourcepub fn enqueue_sync(&self, item: T) -> Result<(), EnqueueError<T>>
pub fn enqueue_sync(&self, item: T) -> Result<(), EnqueueError<T>>
Adds an item
to the end of the queue
Returns back the item
if the queue is full
pub async fn enqueue_async(&self, item: T) -> Result<(), EnqueueError<T>>
pub async fn dequeue_async(&self) -> Result<T, DequeueError>
Trait Implementations§
impl<T, STO: Storage<T>> Sync for MpScQueue<T, STO>where
T: Send,
Auto Trait Implementations§
impl<T, STO> !Freeze for MpScQueue<T, STO>
impl<T, STO> !RefUnwindSafe for MpScQueue<T, STO>
impl<T, STO> Send for MpScQueue<T, STO>
impl<T, STO> Unpin for MpScQueue<T, STO>
impl<T, STO> !UnwindSafe for MpScQueue<T, STO>
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
Mutably borrows from an owned value. Read more