summaryrefslogtreecommitdiff
path: root/test/thread/test_queue.rb
diff options
context:
space:
mode:
authorglass <glass@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-01-14 12:14:48 +0000
committerglass <glass@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-01-14 12:14:48 +0000
commit79e69ec7151662ef6fcb149008d4baab4c4a682c (patch)
tree7c9fdec0248d41ea12244ee42acf7894c4db8fca /test/thread/test_queue.rb
parent0a8988c132164a3a39508fabb863f82c22f7063a (diff)
* ext/thread/thread.c (rb_szqueue_clear): notify SZQUEUE_WAITERS
on SizedQueue#clear. [ruby-core:59462] [Bug #9342] * test/thread/test_queue.rb: add test. the patch is from Justin Collins. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44595 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/thread/test_queue.rb')
-rw-r--r--test/thread/test_queue.rb22
1 files changed, 22 insertions, 0 deletions
diff --git a/test/thread/test_queue.rb b/test/thread/test_queue.rb
index 438e1e75e3..bf8344fade 100644
--- a/test/thread/test_queue.rb
+++ b/test/thread/test_queue.rb
@@ -122,6 +122,28 @@ class TestQueue < Test::Unit::TestCase
assert_same q, retval
end
+ def test_sized_queue_clear
+ # Fill queue, then test that SizedQueue#clear wakes up all waiting threads
+ sq = SizedQueue.new(2)
+ 2.times { sq << 1 }
+
+ t1 = Thread.new do
+ sq << 1
+ end
+
+ t2 = Thread.new do
+ sq << 1
+ end
+
+ t3 = Thread.new do
+ Thread.pass
+ sq.clear
+ end
+
+ [t3, t2, t1].each(&:join)
+ assert_equal sq.length, 2
+ end
+
def test_sized_queue_push_return_value
q = SizedQueue.new(1)
retval = q.push(1)