diff options
author | thedarkone <thedarkone2@gmail.com> | 2016-02-07 19:02:37 +0100 |
---|---|---|
committer | thedarkone <thedarkone2@gmail.com> | 2016-02-07 19:13:16 +0100 |
commit | 5d9e59131312f83f925e2ce59865bcb537976422 (patch) | |
tree | 0ece2ee97881454c03cb134c27c8b4e303b33ac1 /activesupport | |
parent | d2c671e3cffc60ef00df63a28cc9ae0eb89f1b31 (diff) | |
download | rails-5d9e59131312f83f925e2ce59865bcb537976422.tar.gz rails-5d9e59131312f83f925e2ce59865bcb537976422.tar.bz2 rails-5d9e59131312f83f925e2ce59865bcb537976422.zip |
Fix a nonsensical ShareLock test.
Diffstat (limited to 'activesupport')
-rw-r--r-- | activesupport/test/share_lock_test.rb | 43 |
1 files changed, 21 insertions, 22 deletions
diff --git a/activesupport/test/share_lock_test.rb b/activesupport/test/share_lock_test.rb index 5fceebf023..143e65aa0c 100644 --- a/activesupport/test/share_lock_test.rb +++ b/activesupport/test/share_lock_test.rb @@ -341,38 +341,37 @@ class ShareLockTest < ActiveSupport::TestCase threads.each(&:kill) if threads end - def test_manual_recursive_yield + def test_manual_recursive_yield_cannot_expand_outer_compatible ready = Concurrent::CyclicBarrier.new(2) - done = Concurrent::CyclicBarrier.new(2) do_compatible_nesting = Concurrent::CountDownLatch.new + in_compatible_nesting = Concurrent::CountDownLatch.new - threads = [ - Thread.new do - @lock.sharing do - ready.wait - @lock.exclusive(purpose: :x) {} - done.wait - end - end, + incompatible_thread = Thread.new do + @lock.sharing do + ready.wait + @lock.exclusive(purpose: :x) {} + end + end - Thread.new do - @lock.sharing do - ready.wait - @lock.yield_shares(compatible: [:y]) do - do_compatible_nesting.wait - @lock.sharing do - @lock.yield_shares(compatible: [:x, :y]) do - done.wait - end + yield_shares_thread = Thread.new do + @lock.sharing do + ready.wait + @lock.yield_shares(compatible: [:y]) do + do_compatible_nesting.wait + @lock.sharing do + @lock.yield_shares(compatible: [:x, :y]) do + in_compatible_nesting.wait end end end end - ] + end - assert_threads_stuck threads + assert_threads_stuck incompatible_thread do_compatible_nesting.count_down - assert_threads_not_stuck threads + assert_threads_stuck incompatible_thread + in_compatible_nesting.count_down + assert_threads_not_stuck [yield_shares_thread, incompatible_thread] end def test_manual_recursive_yield_restores_previous_compatible |