File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change 255255 specify 'a #post task is never executed when the queue is at capacity' do
256256 lock = Mutex . new
257257 lock . lock
258+
259+ latch = Concurrent ::CountDownLatch . new ( max_threads )
260+
258261 initial_executed = Concurrent ::AtomicFixnum . new ( 0 )
259262 subsequent_executed = Concurrent ::AtomicFixnum . new ( 0 )
260263
261264 # Fill up all the threads (with a task that won't run until
262265 # lock.unlock is called)
263266 max_threads . times do
264- subject . post { lock . lock ; initial_executed . increment ; lock . unlock }
267+ subject . post { latch . count_down ; lock . lock ; initial_executed . increment ; lock . unlock }
265268 end
266269
270+ # Wait for all those tasks to be taken off the queue onto a
271+ # worker thread and start executing
272+ latch . wait
273+
267274 # Fill up the queue (with a task that won't run until
268275 # lock.unlock is called)
269276 max_queue . times do
You can’t perform that action at this time.
0 commit comments