public abstract class Actors
extends java.lang.Object
import static org.gpars.actor.Actors.actor Actors.defaultActorPGroup.resize 1 def actor = actor { react {message -> println message } // this line will never be reached }.start() actor.send 'Hi!'
All actors created through the Actors class will belong to the same default actor group and run on daemon threads. The DefaultPGroup class should be used when actors need to be grouped into multiple groups or when non-daemon threads are to be used.
Modifier and Type | Field and Description |
---|---|
static DefaultPGroup |
defaultActorPGroup
The default actor group to share by all actors created through the Actors class.
|
Constructor and Description |
---|
Actors() |
Modifier and Type | Method and Description |
---|---|
static DefaultActor |
actor(java.lang.Runnable handler)
Creates a new instance of DefaultActor, using the passed-in closure as the body of the actor's act() method.
|
static BlockingActor |
blockingActor(java.lang.Runnable handler)
Creates a new instance of BlockingActor, using the passed-in closure as the body of the actor's act() method.
|
static DefaultActor |
fairActor(java.lang.Runnable handler)
Creates a new instance of PooledActor, using the passed-in closure as the body of the actor's act() method.
|
static Actor |
fairMessageHandler(groovy.lang.Closure code)
Creates an instance of DynamicDispatchActor, which will cooperate in thread sharing with other actors in a fair manner.
|
static Actor |
fairReactor(groovy.lang.Closure code)
Creates a reactor around the supplied code, which will cooperate in thread sharing with other actors in a fair manner.
|
static Actor |
fairStaticMessageHandler(groovy.lang.Closure code)
Creates an instance of StaticDispatchActor, which will cooperate in thread sharing with other actors sharing the same thread pool.
|
static Actor |
messageHandler(groovy.lang.Closure code)
Creates an instance of DynamicDispatchActor.
|
static Actor |
reactor(groovy.lang.Closure code)
Creates a reactor around the supplied code.
|
static Actor |
staticMessageHandler(groovy.lang.Closure code)
Creates an instance of StaticDispatchActor.
|
public static final DefaultPGroup defaultActorPGroup
public static DefaultActor actor(@DelegatesTo(value=DefaultActor.class) java.lang.Runnable handler)
handler
- The body of the newly created actor's act method.public static BlockingActor blockingActor(@DelegatesTo(value=BlockingActor.class) java.lang.Runnable handler)
handler
- The body of the newly created actor's act method.public static DefaultActor fairActor(@DelegatesTo(value=DefaultActor.class) java.lang.Runnable handler)
handler
- The body of the newly created actor's act method.public static Actor reactor(@DelegatesTo(value=Actor.class) groovy.lang.Closure code)
code
- The code to invoke for each received messagepublic static Actor fairReactor(@DelegatesTo(value=Actor.class) groovy.lang.Closure code)
code
- The code to invoke for each received messagepublic static Actor messageHandler(@DelegatesTo(value=Actor.class) groovy.lang.Closure code)
code
- The closure specifying individual message handlers.public static Actor fairMessageHandler(@DelegatesTo(value=Actor.class) groovy.lang.Closure code)
code
- The closure specifying individual message handlers.public static Actor staticMessageHandler(@DelegatesTo(value=Actor.class) groovy.lang.Closure code)
code
- The closure specifying the only statically dispatched message handler.public static Actor fairStaticMessageHandler(@DelegatesTo(value=Actor.class) groovy.lang.Closure code)
code
- The closure specifying the only statically dispatched message handler.