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. When a Turnstyle is dropped, all of its waiters will be notified.

Methods

impl Turnstyle
[src]

Creates a new, empty turnstyle.

Joins the waiting queue.

Returns a tuple of (usize, Waiter) to the caller. The usize represents the waiter's ticket in the queue since creation of the turnstyle, and the Waiter is a future that will complete when the turnstyle turns and reaches the caller's position in the queue.

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]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl Drop for Turnstyle
[src]

Executes the destructor for this type. Read more

Auto Trait Implementations

impl Send for Turnstyle

impl Sync for Turnstyle