Skip to content

Future Design and Implementation

Albert Netymk edited this page Feb 16, 2015 · 2 revisions

GC

GC for non-primitive type inside future:

the producer of f calls gc_send, and inside get we call gc_recv. One boolean flag is used so that gc_recv is only called once so that #gc_recv == #gc_send.

Future Chaining

f' = chain f lambda

The chained closure would always run by the producer of the chained future. In the above example, lambda is run by the producer of f.

Calling get on f' would block the current actor until f' becomes fulfillled due to the running of lambda.

Limitation

Limitation of current implementation:

  1. Calling get on self-fulfilling future causes deadlock.
  2. Passing future to another actor is not supported. Call get, then pass the value instead.
  3. Lambda used in future chaining is run by the producer, which would cause data race.