Sha256: 75b8276a0c8053b764f8d99cbb1536aefe59bd4e75150a1b5adc6090e8486bf2

Contents?: true

Size: 627 Bytes

Versions: 4

Compression:

Stored size: 627 Bytes

Contents

# example of composing futures:

def do_large_computation: x {
  x upto: (x ** x)
}

# FutureSend#&& takes a Block (or a Callable - something that implements 'call:)
# and creates a new FutureSend that executes the given Block with the value of the first FutureSend
# when it has finished its computation. This makes pipelining tasks easy.

f = self @ do_large_computation: 5 && @{select: 'even?} && @{inspect println}
"computing .. " println
f value

#the above is the same as:
# f = self @ do_large_computation: 5
# f = f when_done: @{select: 'even?}
# f = f when_done: @{inspect println}
# "computing .. " println
# f value

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
fancy-0.7.0 examples/future_composition.fy
fancy-0.6.0 examples/future_composition.fy
fancy-0.5.0 examples/future_composition.fy
fancy-0.4.0 examples/future_composition.fy