mirror of
https://github.com/ruby/ruby.git
synced 2025-09-17 01:23:57 +02:00
merge revision(s) 44595: [Backport #9342]
* 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/branches/ruby_2_1@45104 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
1976e3ffd9
commit
a98f024d5c
4 changed files with 46 additions and 1 deletions
|
@ -129,6 +129,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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue