Add `WaitQueue::notify_all()` method
* A convenience method that efficiently wakes up all
`Task`s currently waiting on a `WaitQueue`.
@@ -190,6 +190,15 @@ impl WaitQueue {
self.notify(Some(task_to_wakeup))
}
+ /// Wake up all `Task`s that are waiting on this queue.
+ pub fn notify_all(&self) {
+ for t in self.0.lock().drain(..) {
+ if t.unblock().is_err() {
+ warn!("WaitQueue::notify_all(): failed to unblock {:?}", t);
+ };
+ }
+ }
+
/// The internal routine for notifying / waking up tasks that are blocking on the waitqueue.
/// If specified, the given `task_to_wakeup` will be notified,
/// otherwise the first task on the waitqueue will be notified.
