Active blocks (lambdas) run arbitrary expressions or statement blocks asynchronously.
•Calling a sync function
asynchronously:
•
active {
plainObj.Foo(42) }; // type is future<ReturnType>
Idioms:
•Calling an async function
synchronously:
•
activeObj.Bar(3.14).wait(); //
type is ReturnType
•Calling a function “synchronously”
while leaving the calling thread interruptible:
•
active {
SomeLongOperation() }.wait();
•Creating a callback to do something
when the future materializes.
• future<int> ret = …;
• gcnew active { int i = ret.wait(); DoSomethingWith(i); };