pub struct WakerQueue<T> { /* private fields */ }
Expand description
A ConcurrentQueue with a Waker attached. Allows rapid
implementation of fast channels where at least one side may not be
cloned. Caution: Last Write wins and you are asking for trouble if
there are races registering Wakers. See atomic_waker
for details.
Implementations§
Source§impl<T: 'static + Send> WakerQueue<T>
impl<T: 'static + Send> WakerQueue<T>
Sourcepub fn bounded(size: usize) -> WakerQueue<T>
pub fn bounded(size: usize) -> WakerQueue<T>
Create a WakerQueue with the given capacity.
Sourcepub fn unbounded() -> WakerQueue<T>
pub fn unbounded() -> WakerQueue<T>
Create a WakerQueue which will dynamically resize as required.
Sourcepub fn capacity(&self) -> Option<usize>
pub fn capacity(&self) -> Option<usize>
Returns the maximum capacity of the queue. None for unbounded queues.
Sourcepub fn try_push(&self, value: T) -> Result<(), PushError<T>>
pub fn try_push(&self, value: T) -> Result<(), PushError<T>>
Attempt to push an item into the queue. Will fail if the queue is full or closed.
Sourcepub fn try_push_wake(&self, value: T, wake: bool) -> Result<(), PushError<T>>
pub fn try_push_wake(&self, value: T, wake: bool) -> Result<(), PushError<T>>
Attempts a push. If successful and wake
is true, wakes the
last registered Waker.
Sourcepub fn try_push_wake_empty(&self, value: T) -> Result<(), PushError<T>>
pub fn try_push_wake_empty(&self, value: T) -> Result<(), PushError<T>>
Attempts a push. If successful and the queue was previously empty, wakes the last registered Waker.
Sourcepub fn try_push_wake_full(&self, value: T) -> Result<(), PushError<T>>
pub fn try_push_wake_full(&self, value: T) -> Result<(), PushError<T>>
Attempts a push. If successful and wake
is true, wakes the
last registered Waker.
Sourcepub fn try_pop(&self) -> Result<T, PopError>
pub fn try_pop(&self) -> Result<T, PopError>
Attempts to pop an item from the queue. Will fail if the queue is empty.
Sourcepub fn try_pop_wake(&self, wake: bool) -> Result<T, PopError>
pub fn try_pop_wake(&self, wake: bool) -> Result<T, PopError>
Attempts a pop. If successful and wake
is true, wakes the
last registered Waker.
Sourcepub fn try_pop_wake_empty(&self) -> Result<T, PopError>
pub fn try_pop_wake_empty(&self) -> Result<T, PopError>
Attempts a pop. If successful and the queue was previously empty, wakes the last registered Waker.
Sourcepub fn try_pop_wake_full(&self) -> Result<T, PopError>
pub fn try_pop_wake_full(&self) -> Result<T, PopError>
Attempts a pop. If successful and the queue was previously full, wakes the last registered Waker.
Sourcepub fn push<'a, F>(&'a self, value: T, wake_if: F) -> Push<'a, T, F> ⓘ
pub fn push<'a, F>(&'a self, value: T, wake_if: F) -> Push<'a, T, F> ⓘ
Returns a future which pushes into a WakerQueue
Sourcepub fn pop<'a, F>(&'a self, wake_if: F) -> Pop<'a, T, F> ⓘ
pub fn pop<'a, F>(&'a self, wake_if: F) -> Pop<'a, T, F> ⓘ
Returns a future which pops from a WakerQueue