Expand description
Producer/consumer shared state with async waker-based notification.
This crate provides Producer and Consumer types that share state through
a mutex-protected value. Producers can modify the state and consumers are
automatically notified via async wakers. The channel auto-closes when all
producers are dropped.
For state that both sides legitimately mutate (e.g. a reverse request queue),
Shared is a role-less sibling: every handle can lock, read, or park on a
predicate, with no liveness of its own.
Queue is a poll-native FIFO queue built in the same style: role-less
clone-able handles, bounded or unbounded, with separate wake lists for the
push and pop sides.
Fan hands out a Waker that wakes a whole WaiterList, for
driving a foreign future that keeps a single waker on behalf of everyone parked on it.
It either owns the list or, via Fan::project, wakes one already inside a Lock.
Structs§
- Closed
- The channel closed before the awaited condition held.
- Consumer
- The consuming side of a shared state channel.
- Consumer
Weak - A weak handle from the consuming side (
Consumer::weak). - Fan
- A
WaiterListthat is shared, and that aWakercan wake. - Hold
- Defers wakes on a
Fanuntil dropped. Created byFan::hold. - Lock
- A cloneable mutex wrapper backed by
Arc<Mutex<T>>. - Lock
Guard - A guard providing access to the locked value. Releases the lock on drop.
- Mut
- A mutable guard over the shared state.
- Park
- Holds a parked
Waiterbetween polls, so the registrations it made outlive the poll that made them. - Pending
- Adapts a
Pollableinto aFuture, parking the strongWaiterbetween polls so its weak registration stays live. - Producer
- The producing side of a shared state channel.
- Producer
Weak - A weak handle from the producing side (
Producer::weak). - Queue
- A poll-native FIFO queue with waker notification.
- Ref
- A read-only guard over the shared state.
- Shared
- A cloneable, lock-guarded value with waker notification.
- Waiter
- Handle passed to poll functions for registering with
WaiterLists. - Waiter
List - A list of weak wakers waiting for notification.
- Weak
- A handle that owns nothing at all (
Producer::downgrade). - Weak
Lock - A
Lockthat doesn’t own its value, backed byWeak<Mutex<T>>.
Enums§
- Push
Error - The push failed; the item is handed back.
Traits§
- Pollable
- A pollable computation backed by kio channels.