[][src]Struct waker_queue::WakerQueue

pub struct WakerQueue<T> { /* fields omitted */ }

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

impl<T: 'static + Send> WakerQueue<T>[src]

pub fn bounded(size: usize) -> WakerQueue<T>[src]

Create a WakerQueue with the given capacity.

pub fn unbounded() -> WakerQueue<T>[src]

Create a WakerQueue which will dynamically resize as required.

pub fn is_empty(&self) -> bool[src]

true if the WakerQueue has no items.

pub fn is_full(&self) -> bool[src]

true if the WakerQueue has no spare capacity.

pub fn len(&self) -> usize[src]

Count of items in the WakerQueue

pub fn capacity(&self) -> Option<usize>[src]

Returns the maximum capacity of the queue. None for unbounded queues.

pub fn close(&self)[src]

Closes the queue so that no more items can be pushed. Pops are allowed.

pub fn is_closed(&self) -> bool[src]

true if the queue is closed

pub fn try_push(&self, value: T) -> Result<(), PushError<T>>[src]

Attempt to push an item into the queue. Will fail if the queue is full or closed.

pub fn try_push_wake(&self, value: T, wake: bool) -> Result<(), PushError<T>>[src]

Attempts a push. If successful and wake is true, wakes the last registered Waker.

pub fn try_push_wake_empty(&self, value: T) -> Result<(), PushError<T>>[src]

Attempts a push. If successful and the queue was previously empty, wakes the last registered Waker.

pub fn try_push_wake_full(&self, value: T) -> Result<(), PushError<T>>[src]

Attempts a push. If successful and wake is true, wakes the last registered Waker.

pub fn try_pop(&self) -> Result<T, PopError>[src]

Attempts to pop an item from the queue. Will fail if the queue is empty.

pub fn try_pop_wake(&self, wake: bool) -> Result<T, PopError>[src]

Attempts a pop. If successful and wake is true, wakes the last registered Waker.

pub fn try_pop_wake_empty(&self) -> Result<T, PopError>[src]

Attempts a pop. If successful and the queue was previously empty, wakes the last registered Waker.

pub fn try_pop_wake_full(&self) -> Result<T, PopError>[src]

Attempts a pop. If successful and the queue was previously full, wakes the last registered Waker.

pub fn push<'a, F>(&'a self, value: T, wake_if: F) -> Push<'a, T, F>

Important traits for Push<'a, T, F>

impl<'a, T, F> Future for Push<'a, T, F> where
    T: 'static + Send,
    F: Fn(&'a WakerQueue<T>) -> bool
type Output = Result<(), PushError<T>>;
where
    F: Fn(&'a WakerQueue<T>) -> bool
[src]

Returns a future which pushes into a WakerQueue

pub fn pop<'a, F>(&'a self, wake_if: F) -> Pop<'a, T, F>

Important traits for Pop<'a, T, F>

impl<'a, T, F> Future for Pop<'a, T, F> where
    T: 'static + Send,
    F: Fn(&'a WakerQueue<T>) -> bool
type Output = Result<T, PopError>;
where
    F: Fn(&'a WakerQueue<T>) -> bool
[src]

Returns a future which pops from a WakerQueue

pub fn register(&self, waker: &Waker)[src]

Registers a waker with the WakerQueue.

pub fn wake(&self)[src]

Wakes the last registered Waker, if any.

pub fn wake_if(&self, wake: bool)[src]

Wakes the last registered Waker, if any, if wake is true.

pub fn poll_pop(&self, ctx: &Context) -> Result<T, PopError>[src]

Attempts to pop. If it fails because the queue is empty, it registers the Waker from the provided context.

pub fn poll_push(&self, value: T, ctx: &Context) -> Result<(), PushError<T>>[src]

Attempts to push. If it fails because the queue is full, it registers the Waker from the provided context.

Trait Implementations

impl<T: Debug> Debug for WakerQueue<T>[src]

impl<T: 'static + Send> Send for WakerQueue<T>[src]

impl<T: 'static + Send> Sync for WakerQueue<T>[src]

Auto Trait Implementations

impl<T> !RefUnwindSafe for WakerQueue<T>

impl<T> Unpin for WakerQueue<T> where
    T: Unpin

impl<T> !UnwindSafe for WakerQueue<T>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.