Skip to content
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

Waiter#async: pass options to parent #327

Merged
merged 1 commit into from
Jul 11, 2024
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
4 changes: 2 additions & 2 deletions lib/async/waiter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ def initialize(parent: nil, finished: Async::Condition.new)

# Execute a child task and add it to the waiter.
# @asynchronous Executes the given block concurrently.
def async(parent: (@parent or Task.current), &block)
parent.async do |task|
def async(parent: (@parent or Task.current), **options, &block)
parent.async(**options) do |task|
yield(task)
ensure
@done << task
Expand Down
10 changes: 10 additions & 0 deletions test/async/waiter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,14 @@
waiter.wait
end.to raise_exception(RuntimeError)
end

with 'barrier parent' do
let(:barrier) { Async::Barrier.new }
let(:waiter) { subject.new(parent: barrier) }

it "passes annotation to barrier" do
expect(barrier).to receive(:async).with(annotation: 'waited upon task')
waiter.async(annotation: 'waited upon task') { }
end
end
end
Loading