Expand description
Priority queue for message processing
Enables quality-of-service (QoS) by prioritizing critical messages over low-priority ones. Useful for safety-critical systems where some messages (e.g., emergency stop) must be processed before others (e.g., telemetry).
§Features
- Priority Levels: Define message importance (Critical, High, Normal, Low)
- Fair Processing: Round-robin within same priority level
- Starvation Prevention: Ensures low-priority messages eventually process
- Backpressure Support: Integrates with bounded channels
- Zero-Copy: Messages moved, not copied
§Example
use mecha10::prelude::*;
use mecha10::priority_queue::{PriorityReceiver, Priority};
// Create priority receiver
let mut prio_rx = PriorityReceiver::new();
// Subscribe to multiple topics with different priorities
let emergency = ctx.subscribe("/safety/emergency").await?;
let commands = ctx.subscribe("/motor/command").await?;
let telemetry = ctx.subscribe("/sensor/telemetry").await?;
// Add with priorities
prio_rx.add_source(emergency, Priority::Critical);
prio_rx.add_source(commands, Priority::High);
prio_rx.add_source(telemetry, Priority::Low);
// Process messages in priority order
while let Some((msg, priority)) = prio_rx.recv().await {
match priority {
Priority::Critical => handle_emergency(msg).await?,
Priority::High => handle_command(msg).await?,
_ => handle_telemetry(msg).await?,
}
}Structs§
- Priority
Queue Config - Configuration for priority queue behavior
- Priority
Queue Stats - Statistics about priority queue state
- Priority
Receiver - Priority receiver that processes messages by priority
Enums§
- Priority
- Message priority levels