|
org.codehaus.gpars | |||||||
FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object groovyx.gpars.actor.Actors
@java.lang.SuppressWarningspublic static DefaultActor actor(@DelegatesTo(DefaultActor.class) final Runnable handler) { public abstract class Actors
Provides handy helper methods to create pooled actors and customize the underlying thread pool. Use static import to be able to call Actors methods without the need to prepend them with the Actors identifier.
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.
Field Summary | |
---|---|
static DefaultPGroup |
defaultActorPGroup
|
Constructor Summary | |
Actors()
|
Method Summary | |
---|---|
static DefaultActor
|
actor(java.lang.Runnable handler)
|
static BlockingActor
|
blockingActor(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 DefaultActor
|
fairActor(java.lang.Runnable handler)
Creates a reactor around the supplied code. |
static Actor
|
fairMessageHandler(groovy.lang.Closure code)
|
static Actor
|
fairReactor(groovy.lang.Closure code)
Creates an instance of DynamicDispatchActor. |
static Actor
|
fairStaticMessageHandler(groovy.lang.Closure code)
|
static Actor
|
messageHandler(groovy.lang.Closure code)
|
static Actor
|
reactor(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
|
staticMessageHandler(groovy.lang.Closure code)
|
Methods inherited from class java.lang.Object | |
---|---|
java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll() |
Field Detail |
---|
public static final DefaultPGroup defaultActorPGroup
Constructor Detail |
---|
Actors()
Method Detail |
---|
public static DefaultActor actor(@groovy.lang.DelegatesTo java.lang.Runnable handler)
public static BlockingActor blockingActor(@groovy.lang.DelegatesTo java.lang.Runnable handler)
handler
- The body of the newly created actor's act method.
public static DefaultActor fairActor(@groovy.lang.DelegatesTo java.lang.Runnable handler)
code
- The code to invoke for each received message
public static Actor fairMessageHandler(@groovy.lang.DelegatesTohActor, which will coopera groovy.lang.Closure code)
public static Actor fairReactor(@groovy.lang.DelegatesTocDispatchActor, which will groovy.lang.Closure code)
code
- The closure specifying individual message handlers.
public static Actor fairStaticMessageHandler(@groovy.lang.DelegatesTo groovy.lang.Closure code)
public static Actor messageHandler(@groovy.lang.DelegatesTopatchActor. groovy.lang.Closure code)
public static Actor reactor(@groovy.lang.DelegatesTo groovy.lang.Closure code)
code
- The code to invoke for each received message
public static Actor staticMessageHandler(@groovy.lang.DelegatesTo groovy.lang.Closure code)
Copyright © 2008–2013 Václav Pech. All Rights Reserved.