diff --git a/lib/async/limited_barrier.rb b/lib/async/waiter.rb similarity index 97% rename from lib/async/limited_barrier.rb rename to lib/async/waiter.rb index ee11b526..74a80d41 100644 --- a/lib/async/limited_barrier.rb +++ b/lib/async/waiter.rb @@ -5,7 +5,7 @@ module Async # A composable synchronization primitive, which allows one task to wait for a number of other tasks to complete. It can be used in conjunction with {Semaphore} and/or {Barrier}. - class LimitedBarrier + class Waiter def initialize(parent: nil, finished: Async::Condition.new) @finished = finished @done = [] diff --git a/test/async/limited_barrier.rb b/test/async/waiter.rb similarity index 55% rename from test/async/limited_barrier.rb rename to test/async/waiter.rb index 49965301..4db410f4 100644 --- a/test/async/limited_barrier.rb +++ b/test/async/waiter.rb @@ -1,23 +1,23 @@ -require 'async/limited_barrier' +require 'async/waiter' require 'sus/fixtures/async' -describe Async::LimitedBarrier do +describe Async::Waiter do include Sus::Fixtures::Async::ReactorContext - let(:limited_barrier) {subject.new} + let(:waiter) {subject.new} it "can wait for a subset of tasks" do 3.times do - limited_barrier.async do + waiter.async do sleep(rand * 0.01) end end - done = limited_barrier.wait(2) + done = waiter.wait(2) expect(done.size).to be == 2 - done = limited_barrier.wait(1) + done = waiter.wait(1) expect(done.size).to be == 1 end end