Skip to content

Commit 94e5108

Browse files
authored
Waiter#async: pass options to parent (#327)
1 parent 5a4d8d6 commit 94e5108

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

lib/async/waiter.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ def initialize(parent: nil, finished: Async::Condition.new)
1515

1616
# Execute a child task and add it to the waiter.
1717
# @asynchronous Executes the given block concurrently.
18-
def async(parent: (@parent or Task.current), &block)
19-
parent.async do |task|
18+
def async(parent: (@parent or Task.current), **options, &block)
19+
parent.async(**options) do |task|
2020
yield(task)
2121
ensure
2222
@done << task

test/async/waiter.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,14 @@
4242
waiter.wait
4343
end.to raise_exception(RuntimeError)
4444
end
45+
46+
with 'barrier parent' do
47+
let(:barrier) { Async::Barrier.new }
48+
let(:waiter) { subject.new(parent: barrier) }
49+
50+
it "passes annotation to barrier" do
51+
expect(barrier).to receive(:async).with(annotation: 'waited upon task')
52+
waiter.async(annotation: 'waited upon task') { }
53+
end
54+
end
4555
end

0 commit comments

Comments
 (0)