[−][src]Struct sigq::Queue
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,
I: Send,
impl<I> Sync for Queue<I> where
I: Send,
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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,