Skip to content

Commit

Permalink
Waiter#async: pass options to parent
Browse files Browse the repository at this point in the history
  • Loading branch information
paddor committed Jul 11, 2024
1 parent 975d4d5 commit 8fa7608
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
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

0 comments on commit 8fa7608

Please sign in to comment.