@@ -489,39 +489,39 @@ def behaves_as_delay(delay, value)
489
489
describe 'Throttling' do
490
490
specify do
491
491
limit = 4
492
- throttle = Concurrent ::Promises :: Throttle . new limit
492
+ throttle = Concurrent ::Throttle . new limit
493
493
counter = Concurrent ::AtomicFixnum . new
494
494
testing = -> *args do
495
495
counter . increment
496
- sleep rand * 0.1 + 0.1
496
+ sleep rand * 0.02 + 0.02
497
497
# returns less then 3 since it's throttled
498
498
v = counter . decrement + 1
499
499
v
500
500
end
501
501
502
- expect ( p ( Concurrent ::Promises . zip (
502
+ expect ( Concurrent ::Promises . zip (
503
503
*20 . times . map do |i |
504
504
throttle . throttled { |trigger | trigger . then ( throttle , &testing ) }
505
- end ) . value! ) . all? { |v | v <= limit } ) . to be_truthy
505
+ end ) . value! . all? { |v | v <= limit } ) . to be_truthy
506
506
507
- expect ( p ( Concurrent ::Promises . zip (
507
+ expect ( Concurrent ::Promises . zip (
508
508
*20 . times . map do |i |
509
509
throttle . then_throttled ( throttle , &testing )
510
- end ) . value! ) . all? { |v | v <= limit } ) . to be_truthy
510
+ end ) . value! . all? { |v | v <= limit } ) . to be_truthy
511
511
512
- expect ( p ( Concurrent ::Promises . zip (
512
+ expect ( Concurrent ::Promises . zip (
513
513
*20 . times . map do |i |
514
514
Concurrent ::Promises .
515
515
fulfilled_future ( i ) .
516
516
throttled_by ( throttle ) { |trigger | trigger . then ( throttle , &testing ) }
517
- end ) . value! ) . all? { |v | v <= limit } ) . to be_truthy
517
+ end ) . value! . all? { |v | v <= limit } ) . to be_truthy
518
518
519
- expect ( p ( Concurrent ::Promises . zip (
519
+ expect ( Concurrent ::Promises . zip (
520
520
*20 . times . map do |i |
521
521
Concurrent ::Promises .
522
522
fulfilled_future ( i ) .
523
523
then_throttled_by ( throttle , throttle , &testing )
524
- end ) . value! ) . all? { |v | v <= limit } ) . to be_truthy
524
+ end ) . value! . all? { |v | v <= limit } ) . to be_truthy
525
525
end
526
526
end
527
527
end
0 commit comments