Skip to main content

Module priority_queue

Module priority_queue 

Source
Expand description

§Multi-Level Priority Queue with Anti-Starvation Aging

Provides a five-level priority queue where low-priority items are automatically promoted (“aged”) when they have waited longer than the configured threshold. This prevents starvation of Priority::Background items under sustained Priority::Critical load.

§Example

use tokio_prompt_orchestrator::priority_queue::{
    AgingConfig, MultiLevelQueue, Priority,
};

let config = AgingConfig::default();
let queue: MultiLevelQueue<String> = MultiLevelQueue::new(config);

queue.push("critical task".into(), Priority::Critical);
queue.push("background task".into(), Priority::Background);

// Critical pops first.
assert_eq!(queue.pop(), Some("critical task".into()));
assert_eq!(queue.pop(), Some("background task".into()));
assert_eq!(queue.pop(), None);

Structs§

AgingConfig
Per-level aging thresholds and promotion caps.
MultiLevelQueue
Thread-safe multi-level priority queue with anti-starvation aging.
PriorityItem
A wrapped item with priority metadata.
QueueStats
Aggregate statistics for a MultiLevelQueue.

Enums§

Priority
Five discrete priority levels. Lower numeric value = higher urgency.