Expand description
§Ranked Semaphore - High-Performance Priority Semaphore
A completely safe (zero unsafe) high-performance semaphore implementation with priority queuing. Design goals: zero-cost abstractions, ultra-low latency, minimal memory footprint.
§Core Features
- High Performance: Uncontended path <10ns latency
- Zero unsafe: 100% safe Rust code
- Dynamic Priority: Support for arbitrary priority levels
- Zero Cost: Memory allocation only for actively used priorities
- Batch Optimized: Smart batching reduces lock contention
- Cache Friendly: Optimized memory layout
§Usage Example
use ranked_semaphore::RankedSemaphore;
// Create a semaphore with 3 permits
let semaphore = RankedSemaphore::new_fifo(3);
// Default priority acquisition
let _permit1 = semaphore.acquire().await?;
// High priority acquisition
let _permit2 = semaphore.acquire_with_priority(10).await?;
// Batch acquisition
let _permits = semaphore.acquire_many_with_priority(5, 2).await?;Modules§
- prelude
- Prelude module for commonly used types.
Structs§
- Acquire
- Acquire operation Future
- Acquire
Error - Error returned from acquire operations when the semaphore has been closed.
- Acquire
Owned - Owned acquire operation Future
- Owned
Ranked Semaphore Permit - Semaphore permit (owned version)
- Priority
Config - Configuration for priority-based queue strategies.
- Ranked
Semaphore - High-performance priority semaphore
- Ranked
Semaphore Permit - Semaphore permit (borrowed version)
Enums§
- Queue
Strategy - Queue strategy for waiters at a given priority level.
- TryAcquire
Error - Error returned from try_acquire operations.