Cond

vault class Cond<F>

The Cond type forms a condition variable over one or multiple GuardVars. F is a function type representing the signature of the tasks accepted by runCondition.

Cond is in the Prelude, meaning it is always available and does not need to be imported.

To create a Cond, use the newCondition static method under Guard.

To run a task on a Cond, use the runCondition static method under Guard. Tasks must return a boolean value indicating whether the task was successful. This can be done by using a yield statement to explicitly return a boolean value, or by using a done, retry, or async done statement. An async done statement will additionally perform an async return on the enclosing async fn.

A conditional task follows the all-or-nothing rule like any other lambda: either every code path finishes with async done (or a suffix lambda which async returns on all of its code paths), or none does. retry is allowed either way, since a retried task runs again later. Use async done rather than async return, since a conditional task must yield a boolean. A suffix lambda which async returns on all of its code paths finishes the task, like async done.

API Reference

Methods

signal() -> void

Retry one waiting task.


signalAll() -> void

Retry all waiting tasks.