priority-semaphore
Runtime-agnostic priority aware asynchronous semaphore for Rust.
This crate allows tasks to acquire permits with a signed priority. Higher priorities wake first, making it easy to favour important work while still preventing starvation.
Features
- Works with Tokio or async-std (feature gated)
- Cancellation safe
acquire
- Optional ageing strategy via the
ageing
feature - Zero
unsafe
code
Installation
Add priority-semaphore
to your Cargo.toml
:
[]
= "0.1.2"
Example
use Arc;
use PrioritySemaphore;
async
More examples can be found in the examples
directory.
Documentation
The full API is available at docs.rs.
Crate features
Feature | Default | Description |
---|---|---|
tokio |
✔ | Enable support for the Tokio runtime |
async-std |
❌ | Enable support for async-std |
ageing |
❌ | Simple ageing strategy to reduce starvation |
std |
✔ | Use the standard library |
docsrs |
❌ | Internal feature used by docs.rs |
License
This project is licensed under either the MIT license or the Apache License 2.0, at your option.