Module sync42::wait_list

source ·
Expand description

WaitList provides a collection for synchronizing threads. Internally, the collection owns MAX_CONCURRENCY positions of rendezvous called Waiter (private). You can call WaitList::link to allocate a waiter and return a WaitGuard. Holding a wait guard allows one to construct an iterator or random-accessor over all subsequent threads in the data structure. In this way, the head of the list can iterate the list, batching operations together, and then iterate the list again to distribute the batched work.

See examples/clicker.rs for a concrete, complete example of exactly that.

Structs§

  • Callers link a Waiter into the list and protect it with a WaitGuard. The WaitGuard will panic if the caller fails to unlink.
  • WaitIterator iteratres from the position of the provided guard forward. At each step the iterator will give a guard that lives at least as long as the WaitIterator’s lifetime.
  • WaitList provides the main collection.

Functions§