Struct futures_turnstyle::Turnstyle [−][src]
pub struct Turnstyle { /* fields omitted */ }
An ordered queue of waiting participants.
Every turn of the turnstyle, the next participant in queue is notified and removed from the
queue. If the queue is empty, turn
is a noop. Waiters receive their all-time position
through the turnstyle as their item i.e. the first waiter receives 0, the second receives 1,
etc.
Turnstyles can be cloned and are safe to share across threads.
Methods
impl Turnstyle
[src]
impl Turnstyle
pub fn new() -> Turnstyle
[src]
pub fn new() -> Turnstyle
Creates a new, empty turnstyle.
pub fn join(&self) -> Waiter
[src]
pub fn join(&self) -> Waiter
Joins the waiting queue.
Returns a Waiter
to the caller, which will complete when the turnstyle turns and reaches
the caller's position in the queue.
pub fn turn(&self) -> bool
[src]
pub fn turn(&self) -> bool
Turns once, letting a single waiter through.
The Waiter
is notified by the future completing. The function returns true
if a waiter
was found/notified, false
otherwise.
Trait Implementations
impl Clone for Turnstyle
[src]
impl Clone for Turnstyle
fn clone(&self) -> Turnstyle
[src]
fn clone(&self) -> Turnstyle
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl Drop for Turnstyle
[src]
impl Drop for Turnstyle