We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
TestAtomicThreadPool#test_queue_length
1 parent ff890c6 commit 9ce2910Copy full SHA for 9ce2910
1 file changed
test/atomic-ruby/test_atomic_thread_pool.rb
@@ -89,10 +89,13 @@ def test_length
89
end
90
91
def test_queue_length
92
+ should_sleep = AtomicBoolean.new(true)
93
pool = AtomicThreadPool.new(size: 2)
- 5.times { pool << proc { sleep 1 } }
94
- assert_operator pool.queue_length, :>=, 3
+ 5.times { pool << proc { sleep 0.1 while should_sleep.true? } }
95
+ sleep 0.1
96
+ assert_equal 3, pool.queue_length
97
assert_equal pool.queue_size, pool.queue_length
98
+ should_sleep.make_false
99
pool.shutdown
100
assert_equal 0, pool.queue_length
101
0 commit comments