extra_waiters/
lib.rs

1//!
2//! # `extra_waiters`
3//!
4//! This library provides synchronization primitives built on
5//! top of `parking_lot_core`. The various waiters here are a
6//! mix between a `Condvar` and a `Mutex`, with the specific
7//! details being particular to each waiter.
8//!
9//! Examples of usage can be seen in the test cases written
10//! for each module, however the general pattern for each of
11//! the waiters is as follows:
12//!
13//! ## AttentiveWaiter
14//!
15//! This waiter provides functions to do the following:
16//!
17//! * Not wait for a notification, should one have occurred
18//!   before the last time a notification was polled for.
19//!
20//! * Execute some code before the thread sleeps in a way
21//!   that no thread could notify between the time the
22//!   user code runs and the thread sleeps.
23//!
24//! * Perform the previous two bullet points using timeout
25//!   functions which timeout at a certain `Instant` in time,
26//!   or after a certain `Duration`.
27//!
28//! ## OnceWaiter
29//!
30//! This waiter provides functions to do the following:
31//!
32//! * Ensure that an initialization function is only run
33//!   once.
34//!
35//! * Ensure that an initialization function is only run
36//!   on one thread at a time.
37//!
38//! * Run another thread's initialization function in case
39//!   the currently running one panics.
40//!
41//! * Wait until the waiter is initialized without providing
42//!   an initialization function.
43//!
44//! * Perform the previous bullet points using timeout functions
45//!   which timeout at a certain `Instant` in time, or after
46//!   a certain `Duration`.
47//!
48//! ## Spinlock
49//!
50//! A simple spinlock built on atomic primitives.
51//!
52//! This is not recommended to be used in most instances, however
53//! can be useful in certain cases.
54//!
55
56pub mod attentive_waiter;
57pub mod once_waiter;
58pub mod spinlock_waiter;