Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/optimisticpeach/extra_waiters
https://github.com/optimisticpeach/extra_waiters
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/optimisticpeach/extra_waiters
- Owner: OptimisticPeach
- License: apache-2.0
- Created: 2021-10-06T15:02:00.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2021-10-20T04:53:42.000Z (about 3 years ago)
- Last Synced: 2024-11-16T11:18:31.244Z (about 2 months ago)
- Language: Rust
- Size: 32.2 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE-APACHE2
Awesome Lists containing this project
README
# `extra_waiters`
[![Crate](https://img.shields.io/crates/v/extra_waiters.svg)](https://crates.io/crates/extra_waiters)
[![API](https://docs.rs/extra_waiters/badge.svg)](https://docs.rs/extra_waiters)This library provides synchronization primitives built on
top of `parking_lot_core`. The various waiters here are a
mix between a `Condvar` and a `Mutex`, with the specific
details being particular to each waiter.> Note that the use of this library does not require a `Mutex`.
Examples of usage can be seen in the test cases written
for each module, however the general pattern for each of
the waiters is as follows:## `AttentiveWaiter`
This waiter provides functions to do the following:
* Not wait for a notification, should one have occurred
before the last time a notification was polled for.* Execute some code before the thread sleeps in a way
that no thread could notify between the time the
user code runs and the thread sleeps.* Perform the previous two bullet points using timeout
functions which timeout at a certain `Instant` in time,
or after a certain `Duration`.## `OnceWaiter`
This waiter provides functions to do the following:
* Ensure that an initialization function is only run
once.* Ensure that an initialization function is only run
on one thread at a time.* Run another thread's initialization function in case
the currently running one panics.* Wait until the waiter is initialized without providing
an initialization function.* Perform the previous bullet points using timeout functions
which timeout at a certain `Instant` in time, or after
a certain `Duration`.## `Spinlock`
A simple spinlock built on atomic primitives.
This is not recommended to be used in most instances, however
can be useful in certain cases.