A pooled actor allowing for an alternative structure of the message handling code. In general DynamicDispatchActor repeatedly scans for messages and dispatches arrived messages to one of the onMessage(message) methods defined on the actor.
final class MyActor extends DynamicDispatchActor {* void onMessage(String message) {* println 'Received string' }* void onMessage(Integer message) {* println 'Received integer' }* void onMessage(Object message) {* println 'Received object' }* void onMessage(NullObject nullMessage) {* println 'Received null' }*}Method when {...} provides an alternative way to define message handlers
Modifiers | Name | Description |
---|---|---|
private static long |
serialVersionUID |
Fields inherited from class | Fields |
---|---|
class AbstractLoopingActor |
core, currentSender, currentTimerTask, serialVersionUID, stoppedFlag, terminatedFlag, terminatingFlag, timeoutCounter |
class Actor |
ACTOR_HAS_ALREADY_BEEN_STARTED, AFTER_START, CANNOT_SEND_REPLIES_NO_SENDER_HAS_BEEN_REGISTERED, EMPTY_ARGUMENTS, ON_DELIVERY_ERROR, RESPONDS_TO, START_MESSAGE, STOP_MESSAGE, TERMINATE_MESSAGE, TIMEOUT, TIMEOUT_MESSAGE, currentActorPerThread, currentThread, joinLatch, onStop, parallelGroup, serialVersionUID, timer |
class MessageStream |
serialVersionUID |
class WithSerialId |
serialHandle, serialVersionUID |
Constructor and description |
---|
DynamicDispatchActor
() Creates a new instance without any when handlers registered |
Type | Name and description |
---|---|
DynamicDispatchActor |
become(groovy.lang.Closure closure) Executes the supplied closure in the context of the actor to set all when() handlers |
void |
when(groovy.lang.Closure closure) |
Creates a new instance without any when handlers registered
Executes the supplied closure in the context of the actor to set all when() handlers
closure
- A sequence of when() handlers to set on the actorCopyright © 2008–2014 Václav Pech. All Rights Reserved.