PriorityQueue - Rust #005 - Graceful Shutdown
This video is in French.
In this video, we continue designing our blocking and thread-safe PriorityQueue, adding control over wait times and controlled shutdown modes.
Topics covered
- Simplifying dequeue() and try_dequeue() (no more &mut self needed)
- Securing the constructor with assert!(n_prio > 0)
- Understanding spurious wakeups and using wait_while()
- Implementing a graceful shutdown (shutdown_graceful)
- Implementing a timeout-based shutdown (shutdown_timeout)
- Validation through comprehensive tests: immediate, graceful, and with timeout
Our queue is now safe, predictable and time-controlled, ready to enter the async world.
Useful links
Source code: github.com/xigh/pq-async-rs
PriorityQueue in Rust -- video series
- PriorityQueue - Rust #001
- PriorityQueue - Rust #002 - Fairness
- PriorityQueue - Rust #003 - Multithreading
- PriorityQueue - Rust #004 - Blocking Dequeue
- PriorityQueue - Rust #005 - Graceful Shutdown
- PriorityQueue - Rust #006 - async/await