ranked-semaphore
A priority-aware semaphore for async Rust.
Features
- Priority scheduling: Configurable priority-based task ordering
- No runtime dependency: Works with any async runtime (Tokio, async-std, smol, etc.)
- Flexible queue strategies: FIFO/LIFO and custom strategy
- High performance: Optimized for low latency and high throughput
Quick Start
use RankedSemaphore;
async
Advanced Usage
Priority-based API Rate Limiting
use ;
use Arc;
let config = new
.default_strategy
.exact;
let limiter = new;
let _admin = limiter.acquire_with_priority.await.unwrap;
let _guest = limiter.acquire_with_priority.await.unwrap;
Runtime Support
The semaphore works with any async runtime. Runtime compatibility is ensured through comprehensive integration tests:
# Test Tokio runtime integration
# Test async-std runtime integration
# Test smol runtime integration
# Test futures runtime integration
These tests serve as both verification and usage examples for each runtime.
License
MIT