#primitive #event #async #containing #waiter #future #handful

casus

A simple library containing a handful of event-based async primitives

1 unstable release

0.1.0 Dec 31, 2022

#1458 in Asynchronous

MIT license

9KB
119 lines

casus

Casus is a simple library containing a handful of useful generic async primitives. At present, it contains Event and Waiter primitives.

Event

The Event primitive allows a future to await the completion of an event. Once the event is completed, all futures trying to await it will immediately return and continue until the event is reset.

use casus::Event;

let event = Event::new();

// this will block until Event::set is called elsewhere
event.wait().await;

Waiter

The Waiter primitive simply waits to be woken up with it's return value.

use casus::Waiter;

let waiter = Waiter::new();

// this will block until Event::wake is called elsewhere
waiter.await;

lib.rs:

Casus is a simple library containing a handful of useful generic async primitives. At present, it contains Event and Waiter primitives.

Event

The Event primitive allows a future to await the completion of an event. Once the event is completed, all futures trying to await it will immediately return and continue until the event is reset.

use casus::Event;

let event = Event::new();

// this will block until Event::set is called elsewhere
event.wait().await;

Waiter

The Waiter primitive simply waits to be woken up with it's return value.

use casus::Waiter;

let waiter = Waiter::new();

// this will block until Event::wake is called elsewhere
waiter.await;

No runtime deps