+act,sam,doc #3940 Added receive setter for Java Lambda actors
* Added a setter for Java lambda actors to "hide" the not so nice looking type signature of the "receive" method. * Updated docs to reflect the changes. * Converted samples to use the new setter.
This commit is contained in:
parent
30ae25a90c
commit
723c931d16
23 changed files with 683 additions and 570 deletions
|
|
@ -43,8 +43,8 @@ public class DiningHakkersOnBecome {
|
|||
}).build();
|
||||
|
||||
//A Chopstick begins its existence as available
|
||||
public PartialFunction<Object, BoxedUnit> receive() {
|
||||
return available;
|
||||
public Chopstick() {
|
||||
receive(available);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -125,11 +125,11 @@ public class DiningHakkersOnBecome {
|
|||
}).build();
|
||||
|
||||
//All hakkers start in a non-eating state
|
||||
public PartialFunction<Object, BoxedUnit> receive() {
|
||||
return ReceiveBuilder.matchEquals(Think, m -> {
|
||||
public Hakker() {
|
||||
receive(ReceiveBuilder.matchEquals(Think, m -> {
|
||||
System.out.println(String.format("%s starts to think", name));
|
||||
startThinking(Duration.create(5, SECONDS));
|
||||
}).build();
|
||||
}).build());
|
||||
}
|
||||
|
||||
private void startThinking(FiniteDuration duration) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue