[][src]Struct sigq::Queue

pub struct Queue<I> { /* fields omitted */ }

Implementations

impl<I> Queue<I>[src]

pub fn new() -> Self[src]

Create, and return, a new queue.

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

Returns a boolean indicating whether the queue was empty or not.

This function is not particularly useful. If you don't understand why, then please don't use it.

pub fn push(&self, item: I)[src]

Push a node on to the queue and unlock one queue reader, if any.

pub fn pop(&self) -> I[src]

Pull the oldest node off the queue and return it. If no nodes are available on the queue, then block and wait for one to become available.

pub fn try_pop(&self) -> Option<I>[src]

Pull the oldest node off the queue and return it. If no nodes are available on the queue, then return None.

pub fn apop(&self) -> PopFuture<I>[src]

This method serves the same purpose as the pop() method, but rather than block it returns a Future to be used in an async context.

use sigq::Queue;
async fn test() {
  let q = Queue::new();
  q.push("hello".to_string());
  assert_eq!(q.was_empty(), false);
  let node = q.apop().await;
  assert_eq!(node, "hello");
  assert_eq!(q.was_empty(), true);
}

Auto Trait Implementations

impl<I> !RefUnwindSafe for Queue<I>

impl<I> Send for Queue<I> where
    I: Send

impl<I> Sync for Queue<I> where
    I: Send

impl<I> Unpin for Queue<I>

impl<I> !UnwindSafe for Queue<I>

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.