Module tarantool::fiber::async::oneshot

source ·
Expand description

A one-shot channel is used for sending a single message between asynchronous tasks. The channel function is used to create a Sender and Receiver handle pair that form the channel.

The Sender handle is used by the producer to send the value. The Receiver handle is used by the consumer to receive the value.

Each handle can be used on separate fiber.

Since the send method is not async it can be used from non-async code.


use tarantool::fiber::r#async::oneshot;
use tarantool::fiber;

let (tx, rx) = oneshot::channel::<i32>();
let value = fiber::block_on(rx);

If the sender is dropped without sending, the receiver will fail with super::RecvError:


Receives a value from the associated Sender.
Sends a value to the associated Receiver.


Creates a new one-shot channel for sending single values across asynchronous tasks.