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 255
255
specify 'a #post task is never executed when the queue is at capacity' do
256
256
lock = Mutex . new
257
257
lock . lock
258
+
259
+ latch = Concurrent ::CountDownLatch . new ( max_threads )
260
+
258
261
initial_executed = Concurrent ::AtomicFixnum . new ( 0 )
259
262
subsequent_executed = Concurrent ::AtomicFixnum . new ( 0 )
260
263
261
264
# Fill up all the threads (with a task that won't run until
262
265
# lock.unlock is called)
263
266
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 }
265
268
end
266
269
270
+ # Wait for all those tasks to be taken off the queue onto a
271
+ # worker thread and start executing
272
+ latch . wait
273
+
267
274
# Fill up the queue (with a task that won't run until
268
275
# lock.unlock is called)
269
276
max_queue . times do
You can’t perform that action at this time.
0 commit comments