summaryrefslogtreecommitdiff
path: root/test/thread/test_queue.rb
diff options
context:
space:
mode:
authorcharliesome <charliesome@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-01-13 03:18:38 +0000
committercharliesome <charliesome@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-01-13 03:18:38 +0000
commit64926db998b94189eb7d61d7d924ae69f25c205c (patch)
treefab651293e56f8976c27ab5387c7ae97642d6505 /test/thread/test_queue.rb
parent23a85687398e0fc620c07ca87237d9b384cee53e (diff)
* ext/thread/thread.c (rb_szqueue_push): check GET_SZQUEUE_WAITERS
instead of GET_QUEUE_WAITERS to prevent deadlock. Patch by Eric Wong. [Bug #9302] [ruby-core:59324] * test/thread/test_queue.rb: add test git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44583 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/thread/test_queue.rb')
-rw-r--r--test/thread/test_queue.rb23
1 files changed, 23 insertions, 0 deletions
diff --git a/test/thread/test_queue.rb b/test/thread/test_queue.rb
index 563b91e748..438e1e75e3 100644
--- a/test/thread/test_queue.rb
+++ b/test/thread/test_queue.rb
@@ -134,6 +134,29 @@ class TestQueue < Test::Unit::TestCase
assert_same q, retval
end
+ def test_sized_queue_throttle
+ q = SizedQueue.new(1)
+ i = 0
+ consumer = Thread.new do
+ while q.pop
+ i += 1
+ Thread.pass
+ end
+ end
+ nprod = 4
+ npush = 100
+
+ producer = nprod.times.map do
+ Thread.new do
+ npush.times { q.push(true) }
+ end
+ end
+ producer.each(&:join)
+ q.push(nil)
+ consumer.join
+ assert_equal(nprod * npush, i)
+ end
+
def test_queue_thread_raise
q = Queue.new
th1 = Thread.new do