next up previous contents
Next: Join Blocks Up: Coordinating Concurrency Previous: Coordinating Concurrency


Token-Passing Continuations

Token-passing continuations are designed to specify a partial order of message processing. The token '@' is used to group messages and assigns the execution order to each of them. For instance, the following example forces the standardOutput actor, a predefined system actor for output, to print out "Hello World":
 
standardOutput <- print("Hello ") @ 
standardOutput <- print("World");
 
   
If a programmer uses ';' instead of '@', SALSA does not guarantee that the standardOutput actor will print out "Hello World". It is possible to have the result "WorldHello ". The following example shows the non-deterministic case:
 
standardOutput <- print("Hello ");  
standardOutput <- print("World");
 
   
A SALSA message handler can return a value, and the value can be accessed through a reserved keyword ' token', specified in one of the arguments of the next grouped message. For instance, assuming there exists a user-defined message handler, returnHello(), which returns a string "Hello". The following example prints out "Hello" to the standard output:
 
// returnHello() is defined as the follows:
//    String returnHello() {return "Hello";}
returnHello() @  standardOutput <- println(token);
 
   
Again, assuming another user-defined message handler combineStrings() accepts two input Strings and returns a combined string of the inputs, the following example prints out "Hello World" to the standard output:
 
// combineStrings() is defined as follows:
// String combineStrings(String str1, String str2) 
//   {return str1+str2;}
returnHello() @  
combineStrings(token, " World") @ 
standardOutput <- println(token);
 
   
Note that the first token refers to the return value of returnHello(), and the second token refers to that of combineStrings(token, " World").


next up previous contents
Next: Join Blocks Up: Coordinating Concurrency Previous: Coordinating Concurrency
Wei-Jen Wang
2007-11-28