Skip to main content

Module waiter

Module waiter 

Source
Expand description

Facility to wait for a dynamic set of tasks to complete, with a single waiter and multiple waitees (things that are waited for). Notably, each waitee can also start more work to be waited for.

§Implementation Details

The implementation of waiting in this module is just a wrapper around tokio::sync::mpsc::channel. A WaitGroup holds the unique tokio::sync::mpsc::Receiver and each WaitGuard holds a tokio::sync::mpsc::Sender. Despite this simple implementation, the WaitGroup and WaitGuard wrappers are useful to make this discoverable.

Structs§

WaitGroup
Manager for a particular wait group. This can spawn a number of WaitGuards and it can then wait for them to all complete.
WaitGuard
RAII guard held by a task which is being waited for.

Functions§

fibonacci_waiter_example 🔒
Demonstrates use of the WaitGroup and WaitGuard to (very inefficiently) compute the Fibonacci number F(n) using recursive channels.
fibonacci_waiter_example_task 🔒
An inefficient Fibonacci implementation. This computes F(n) by sending by n-1 and n-2 back into the channel. This shows how one work item can create multiple subsequent work items.