Groovy Documentation

gpars.actor
Class DynamicDispatchActor

java.lang.Object
  groovyx.gpars.actor.impl.SequentialProcessingActor
      gpars.actor.AbstractPooledActor
          gpars.actor.DynamicDispatchActor

@SuppressWarnings("GroovyAssignmentToMethodParameter")
class DynamicDispatchActor
extends AbstractPooledActor

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
author:
Vaclav Pech, Alex Tkachman, Dierk Koenig Date: Jun 26, 2009


Constructor Summary
DynamicDispatchActor()

Creates a new instance without any when handlers registered

DynamicDispatchActor(groovy.lang.Closure closure)

Creates an instance, processing all when{} calls in the supplied closure

 
Method Summary
void act()

Loops reading messages using the react() method and dispatches to the corresponding onMessage() method.

void when(groovy.lang.Closure closure)

 
Methods inherited from class AbstractPooledActor
act, doOnException, doOnInterrupt, doOnStart, doOnTermination, doOnTimeout, onStop, receive, receive, receive, receiveImpl, receiveImpl, sweepQueue
 

Constructor Detail

DynamicDispatchActor

public DynamicDispatchActor()
Creates a new instance without any when handlers registered


DynamicDispatchActor

public DynamicDispatchActor(groovy.lang.Closure closure)
Creates an instance, processing all when{} calls in the supplied closure
param:
closure A closure to run against te actor, typically to register handlers


 
Method Detail

act

public final void act()
Loops reading messages using the react() method and dispatches to the corresponding onMessage() method.


when

void when(groovy.lang.Closure closure)


 

Groovy Documentation