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)
223
223
224
224
alias_method :then , :chain
225
225
226
+ def chain_completable ( completable_event )
227
+ on_completion! { completable_event . complete_with COMPLETED }
228
+ end
229
+
230
+ alias_method :tangle , :chain_completable
231
+
226
232
# Zip with future producing new Future
227
233
# @return [Event]
228
234
def zip ( other )
@@ -606,6 +612,12 @@ def then_ask(actor)
606
612
self . then { |v | actor . ask ( v ) } . flat
607
613
end
608
614
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
+
609
621
# @yield [reason] executed only on parent failure
610
622
# @return [Future]
611
623
def rescue ( executor = nil , &callback )
Original file line number Diff line number Diff line change 3
3
4
4
describe 'Concurrent::Edge futures' do
5
5
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
+
6
23
describe '.post' do
7
24
it 'executes tasks asynchronously' do
8
25
queue = Queue . new
You can’t perform that action at this time.
0 commit comments