File tree Expand file tree Collapse file tree 1 file changed +9
-26
lines changed Expand file tree Collapse file tree 1 file changed +9
-26
lines changed Original file line number Diff line number Diff line change @@ -371,36 +371,19 @@ def get_ivar_from_args(opts)
371
371
372
372
it 'preserves ordering of the executed promises' do
373
373
10 . times do
374
- running = Mutex . new
375
- cond = ConditionVariable . new
376
- cond2 = ConditionVariable . new
374
+ latch1 = CountDownLatch . new
375
+ latch2 = CountDownLatch . new
377
376
executor = SimpleExecutorService . new
378
377
379
- p1 = Concurrent ::Promise . execute ( executor : executor ) do
380
- running . synchronize do
381
- cond . wait ( running )
382
- 'one'
383
- end
384
- end
385
-
386
- p2 = Concurrent ::Promise . execute ( executor : executor ) do
387
- running . synchronize do
388
- cond2 . wait ( running )
389
- 'two'
390
- end
391
- end
392
-
393
- p3 = Concurrent ::Promise . execute ( executor : executor ) do
394
- running . synchronize do
395
- 'three'
396
- end
397
- end
378
+ p1 = Concurrent ::Promise . execute ( executor : executor ) { latch1 . wait ; 'one' }
379
+ p2 = Concurrent ::Promise . execute ( executor : executor ) { latch2 . wait ; 'two' }
380
+ p3 = Concurrent ::Promise . execute ( executor : executor ) { 'three' }
398
381
399
- cond2 . signal
400
- cond . signal
382
+ latch1 . count_down
383
+ latch2 . count_down
401
384
402
- result = Concurrent ::Promise . zip ( p1 , p2 , p3 ) . value
403
- expect ( result ) . to eq ( [ 'one' , 'two' , 'three' ] )
385
+ result = Concurrent ::Promise . zip ( p1 , p2 , p3 ) . value!
386
+ expect ( result ) . to eq ( [ 'one' , 'two' , 'three' ] )
404
387
end
405
388
end
406
389
end
You can’t perform that action at this time.
0 commit comments