Chapter 3 skips some details of join blocks. This section introduces how to use the return values of statements inside a join block and by implementing message handlers which can receive the result of a join block.
A join block always returns an object array if it joins several messages to a reserved keyword token, or a named token. If those message handlers to be joined do not return (void type return), or the return values are ignored, the join block functions like a barrier for parallel message processing.
The named token can be applied to the join block as follows:
1. token x = join {
2. a<-m1();
3. b<-m2();
4. };
|
1. behavior JoinContinuation {
2.
3. int multiply(Object numbers[]){
4. return ((Integer)numbers[0]).intValue() *
5. ((Integer)numbers[1]).intValue() *
6. ((Integer)numbers[2]).intValue();
7. }
8.
9. int add(int n1, int n2) {
10. return n1 + n2;
11. }
12.
13. void act(String args[]) {
14.
15. standardOutput<-print("Value: ") @
16. join {
17. add(2,3);
18. add(3,4);
19. add(2,4);
20. } @ multiply( token ) @ standardOutput<-println( token );
21. }
22.
23.}
|