2
Return values are future values:
•Calling an active object method is nonblocking, but a return value (and “out” arguments) cannot be used until an explicit wait for the future to materialize.
• active class Calc {
  public: double TotalOrders() { return ComputeSomething(); }
};
• // in calling code, using a Calc object
future<double> tot = calc.TotalOrders(); // call is nonblocking
… potentially lots of work … // parallel work
DoSomethingWith( tot.wait() ); // explicitly wait to accept
Why require explicit wait? Four compelling reasons:
•No silent loss of concurrency (e.g., early “logFile << tot;”).
•Explicit block point for writing into lent objects (“out” args).
•Explicit point for emitting exceptions.
•Need to be able to pass futures onward to other code (e.g., DoSomethingWith( tot ) ≠ DoSomethingWith( tot.wait() )).
Futures