asynchronous combinator library for D
Futures are values yet to be computed. They are
shared and thread-safe.
Futures receive a pending value with
fulfill, and can actively forward the received value to callback delegates registered with
example: executing a function in another thread
f :: A -> B, then
async!f :: A -> Future!(Result!B).
f(a) = b and
async!f(a) = c.
async!f will execute
f in a separate thread when invoked.
f is being computed,
b == c.result.success.
c.result.failure is inhabited with the caught error.
Attempting to read
c.isReady is an error.
async!f can be made blocking at any time with
c so that
c.await.result == c.result.
For a futures
b, and arguments
a.then!f(c) returns a future which contains
f(a.result, c) when
a is ready
a.next!f(c) chains two futures (
f(a.result, c)) into a single future
a.result is also a future,
sync(a) joins the inner and outer futures of
a (like a lazy
when(a,b) is a future
Tuple(a.result, b.result), ready when both
b are ready
race(a,b) is a future
Union(a.result, b.result), ready when either
b are ready
detailed documentation and examples
is contained in the
dependency "future" version="0.1.0"