Skip to content

Commit b80d707

Browse files
committed
Corrected example use of Concurrent::dataflow
1 parent 9b56345 commit b80d707

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

lib/concurrent/dataflow.rb

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,17 @@ def update(time, value, reason)
3636
# @example Parallel Fibonacci calculator
3737
# def fib(n)
3838
# if n < 2
39-
# Concurrent::Future.new { n }
39+
# Concurrent::dataflow { n }
4040
# else
41-
# n1 = fib(n - 1).execute
42-
# n2 = fib(n - 2).execute
43-
# Concurrent::Future.new { n1.value + n2.value }
41+
# n1 = fib(n - 1)
42+
# n2 = fib(n - 2)
43+
# Concurrent::dataflow(n1, n2) { |v1, v2| v1 + v2 }
4444
# end
4545
# end
46-
#
47-
# f = fib(14) #=> #<Concurrent::Future:0x000001019ef5a0 ...
48-
# f.execute #=> #<Concurrent::Future:0x000001019ef5a0 ...
49-
#
46+
#
47+
# f = fib(14) #=> #<Concurrent::Future:0x000001019a26d8 ...
5048
# sleep(0.5)
51-
#
49+
#
5250
# f.value #=> 377
5351
#
5452
# @param [Future] inputs zero or more +Future+ operations that this dataflow depends upon

0 commit comments

Comments
 (0)