Crate futures_shuttle [] [src]

Futures-based Shuttle

A channel for shuttling a single object/message back and forth between two asynchronous tasks. Contrary to the mutex or lock, shuttle always belongs to one of the two tasks. The side that owns the control over Shuttle at a specific moment can manipulate its content and send it to the other side. At this point control goes over to the other side and the original side loses the ability to access the Shuttle object. It, however, can wait for Shuttle to come back from the other side of the track, and then regain the access.



This is created by the shuttle function.


ShuttleValue is a guard for the object inside Shuttle, much like MutexGuard' forMutex`.


ShuttleWait object is a Future that waits for Shuttle to arrive back. I.e. it completes when the other side calls send on its object and the ownership turns to this object. ShuttleWait is created when Shuttle is converted into Future (it implements IntoFuture) and it consumes the Shuttle object. When the future completes it yields the Shuttle object back.



Describes the possible error state of the Shuttle object.



Creates a new shuttle synchronization object for sharing values between two asynchronous tasks.