AwaitState
A minimal, powerful async state coordination map for Rust — wait for state changes, not just values.
AwaitState lets you insert state into a concurrent map and await custom transitions using user-defined predicates. Built on tokio and dashmap, it offers a simple but robust way to coordinate async tasks by state — with support for previous/current value tracking and notification on change.
Features
- Track both previous and current state
- Wait for custom state transitions using predicates
- Efficient notification without polling (uses
tokio::Notify) - Backed by
DashMapfor thread-safe concurrent access - Lightweight, no macros, no codegen — just a few hundred LOC
Example
use AwaitStateMap;
use Arc;
use Duration;
async
Use Cases
-
Download manager state tracking
-
Distributed job coordination
-
Reactive actor models
-
Awaitable per-key state transitions
-
Async workflows with checkpointing
Status
AwaitState is small, focused, and production-ready. It's designed for projects that want to coordinate async work with as little boilerplate as possible.
License
MIT or Apache 2.0 -- your choice
Contributing
Contributions, feedback, and design discussions are welcome!