Skip to content

Rename Async::LimitedBarrier to Async::Waiter based on feedback. #196

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/async/limited_barrier.rb → lib/async/waiter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down
12 changes: 6 additions & 6 deletions test/async/limited_barrier.rb → test/async/waiter.rb
Original file line number Diff line number Diff line change
@@ -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