File tree Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -223,6 +223,12 @@ def chain(executor = nil, &callback)
223223
224224 alias_method :then , :chain
225225
226+ def chain_completable ( completable_event )
227+ on_completion! { completable_event . complete_with COMPLETED }
228+ end
229+
230+ alias_method :tangle , :chain_completable
231+
226232 # Zip with future producing new Future
227233 # @return [Event]
228234 def zip ( other )
@@ -606,6 +612,12 @@ def then_ask(actor)
606612 self . then { |v | actor . ask ( v ) } . flat
607613 end
608614
615+ def chain_completable ( completable_future )
616+ on_completion! { completable_future . complete_with internal_state }
617+ end
618+
619+ alias_method :tangle , :chain_completable
620+
609621 # @yield [reason] executed only on parent failure
610622 # @return [Future]
611623 def rescue ( executor = nil , &callback )
Original file line number Diff line number Diff line change 33
44describe 'Concurrent::Edge futures' do
55
6+ describe 'chain_completable' do
7+ it 'event' do
8+ b = Concurrent . event
9+ a = Concurrent . event . chain_completable ( b )
10+ a . complete
11+ expect ( b ) . to be_completed
12+ end
13+
14+ it 'future' do
15+ b = Concurrent . future
16+ a = Concurrent . future . chain_completable ( b )
17+ a . success :val
18+ expect ( b ) . to be_completed
19+ expect ( b . value ) . to eq :val
20+ end
21+ end
22+
623 describe '.post' do
724 it 'executes tasks asynchronously' do
825 queue = Queue . new
You can’t perform that action at this time.
0 commit comments