2 unstable releases
new 0.2.0 | Apr 5, 2025 |
---|---|
0.1.0 | Apr 1, 2025 |
#1495 in #future
151 downloads per month
Used in limqch
7KB
87 lines
wakerizer
Helpers for async resources that may have multiple wakers.
lib.rs
:
wakerizer is intended to be used to keep track of multiple Future
s
waiting for a single (shared) resource.
It can assist in developing behaviors vaguely similar to Condvar
's
notify_all()
.
Usage
A resource that may be waited on creates and stores a Wakers
object.
Each time a Future
is created that will be waiting for the resource, its
Wakers
spawns a Waiter
, which is stored with the Future
.
If the Future's poll()
function returns Poll::Pending
, it calls its
Waiter::prime()
to indicate that it is a Future that is actively waiting.
Whenever the resource is ready, it can signal waiting futures using
[Wakers::wake_all()
].
Dependencies
~0.4–5MB
~11K SLoC