@@ -489,39 +489,39 @@ def behaves_as_delay(delay, value)
489489 describe 'Throttling' do
490490 specify do
491491 limit = 4
492- throttle = Concurrent ::Promises :: Throttle . new limit
492+ throttle = Concurrent ::Throttle . new limit
493493 counter = Concurrent ::AtomicFixnum . new
494494 testing = -> *args do
495495 counter . increment
496- sleep rand * 0.1 + 0.1
496+ sleep rand * 0.02 + 0.02
497497 # returns less then 3 since it's throttled
498498 v = counter . decrement + 1
499499 v
500500 end
501501
502- expect ( p ( Concurrent ::Promises . zip (
502+ expect ( Concurrent ::Promises . zip (
503503 *20 . times . map do |i |
504504 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
506506
507- expect ( p ( Concurrent ::Promises . zip (
507+ expect ( Concurrent ::Promises . zip (
508508 *20 . times . map do |i |
509509 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
511511
512- expect ( p ( Concurrent ::Promises . zip (
512+ expect ( Concurrent ::Promises . zip (
513513 *20 . times . map do |i |
514514 Concurrent ::Promises .
515515 fulfilled_future ( i ) .
516516 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
518518
519- expect ( p ( Concurrent ::Promises . zip (
519+ expect ( Concurrent ::Promises . zip (
520520 *20 . times . map do |i |
521521 Concurrent ::Promises .
522522 fulfilled_future ( i ) .
523523 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
525525 end
526526 end
527527end
0 commit comments