Module tarantool::fiber::async::watch

source ·
Expand description

A single-producer, multi-consumer channel that only retains the last sent value.

This channel is useful for watching for changes to a value from multiple points in the code base, for example, changes to configuration values.


channel returns a Sender / Receiver pair. These are the producer and sender halves of the channel. The channel is created with an initial value. The latest value stored in the channel is accessed with Receiver::borrow(). Awaiting Receiver::changed() waits for a new value to sent by the Sender half.


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

let (tx, mut rx) = watch::channel::<i32>(10);
let value = fiber::block_on(async move {


Sender::is_closed allows the producer to detect when all Receiver handles have been dropped. This indicates that there is no further interest in the values being produced and work can be stopped.


Future that returns when a new value is published in Sender.
Receives values from the associated Sender.
Error produced when sending a value fails.
Sends values to the associated Receiver.
Returns a reference to the inner value.


Creates a new watch channel, returning the “send” and “receive” handles.