Skip to main content

Crate frugal_async

Crate frugal_async 

Source
Expand description

This crate provides utilities for writing async Rust code. Unlike many other such crates, it makes a couple of simplifying assumptions:

  • no cancel-safety required,
  • futures need not be Send, and
  • panics always abort the program.

See Frugal Async Rust for more details on these assumptions.

§Synchronisation

We provide two .awaitable synchronisation primitives: Mutex provides exclusive access to a wrapped value, and RwLock provides exclusive mutable access or an arbitrary number of concurrent immutable accesses to a wrapped value (think an awaitable RefCell).

§Cells

The OnceCell is a cell which starts empty and can be set to a value only once; calling code can .await the moment the cell is set to a value.

The TakeCell is a cell which starts empty, whose contents can be set to any value any number of times, and whocse contents can only be accessed through an async take method which empties the cell (and which is parked when called on a presently-empty cell).

Re-exports§

pub use rw::RwLock;
pub use mutex::Mutex;

Modules§

mutex
An awaitable, single-threaded mutex.
rw
An awaitable, single-threaded read-write lock.

Structs§

OnceCell
An optional value that can be set to a Some at most once, and which allows to .await that time.
TakeCell
An async cell akin to an Option, whose value can only be accessed via an async take method that non-blocks while the cell is empty.