diff --git a/lib/async/waiter.rb b/lib/async/waiter.rb index f26fccc0..bd911c99 100644 --- a/lib/async/waiter.rb +++ b/lib/async/waiter.rb @@ -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 diff --git a/test/async/waiter.rb b/test/async/waiter.rb index abac85f1..329a876f 100644 --- a/test/async/waiter.rb +++ b/test/async/waiter.rb @@ -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