From 5f15e26a7d2c05aa92bf9bb1c404daf3f5c4778b Mon Sep 17 00:00:00 2001 From: Justin Collins Date: Wed, 1 Jan 2014 22:50:33 -0800 Subject: [PATCH] Wake waiting threads when SizedQueue#clear is called (2.0.0) --- lib/thread.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/thread.rb b/lib/thread.rb index 1c81070..94f8d10 100644 --- a/lib/thread.rb +++ b/lib/thread.rb @@ -352,6 +352,16 @@ class SizedQueue < Queue alias deq pop # + # Removes all objects from the queue and wakes waiting threads, if any. + # + def clear + @mutex.synchronize do + @que.clear + @enque_cond.signal + end + end + + # # Returns the number of threads waiting on the queue. # def num_waiting -- 1.8.3.2