User Tools

Site Tools


at:tutorial:actors

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revisionBoth sides next revision
at:tutorial:actors [2007/04/06 20:40] – added tvcutsemat:tutorial:actors [2007/04/06 20:50] tvcutsem
Line 253: Line 253:
 }; };
 </code> </code>
 +
 +The ''when:*'' functions are a very easy mechanism to synchronise on the value of a future without actually making an actor block: remember that all the ''when:becomes:'' function does is register the closure with the future. After that, the actor simply continues processing the statement following ''when:becomes:''. Also, even if the future is already resolved at the time the closure observer is registered, the closure is guaranteed to be applied asynchronously. This ensures that the code following a ''when:becomes:'' block is guaranteed to be executed before the registered closure itself:
 +
 +<code>
 +when: sumFuture becomes: { |sum|
 +  system.println("... and here later.");
 +};
 +system.print("Always here first");
 +>>Always here first... and here later.
 +</code>
 +
 +=== Futures and Striped Messages ===
 +
 +Explain:
 +''o<-m()@FutureMessage''
 +''o<-m()@OneWayMessage''
 +
 +=== Conditional Synchronisation with Futures ===
 +
 +explain: explicit futures using ''makeFuture''
  
 ==== Actor Mirrors ==== ==== Actor Mirrors ====
at/tutorial/actors.txt · Last modified: 2020/02/05 21:26 by elisag