PriorityQueue - Rust #004 - Blocking Dequeue
This video is in French.
In this video, we continue building our concurrent Priority Queue. This time we add a blocking version of the dequeue() method and handle controlled shutdown with shutdown_immediate().
Topics covered
- Why
try_dequeue()is not sufficient (the polling problem) - Designing a blocking
dequeue()method withCondvar - The wait predicate
(!pq.is_empty()) || closed - Handling spurious wakeups
- The mutation-then-notification order for safe behavior
- Implementing a clean and consistent immediate shutdown (
shutdown_immediate)
An important step before introducing graceful shutdowns and timeouts in the next video.
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