|
Groovy Documentation | |||||||
FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectgroovyx.gpars.actor.Actor
gpars.actor.impl.SequentialProcessingActor
@SuppressWarnings({"UnqualifiedStaticUsage"}) public abstract class SequentialProcessingActor extends Actor
Field Summary | |
---|---|
protected static int |
S_ACTIVE_MASK
|
protected static int |
S_FINISHED_MASK
|
protected static int |
S_FINISHING_MASK
|
protected static int |
S_NOT_STARTED
|
protected static int |
S_RUNNING
|
protected static int |
S_STOPPED
|
protected static int |
S_STOPPING
|
protected static int |
S_STOP_TERMINATE_MASK
|
protected static int |
S_TERMINATED
|
protected static int |
S_TERMINATING
|
protected PGroup |
actorGroup
The actor group to which the actor belongs |
protected Runnable |
loopCode
Code for the loop, if any |
protected int |
stopFlag
Indicates whether the actor should terminate |
protected static AtomicIntegerFieldUpdater |
stopFlagUpdater
|
Constructor Summary | |
protected SequentialProcessingActor()
Creates a new instance, sets the default actor group. |
Method Summary | |
---|---|
protected void
|
checkStopTerminate()
|
protected void
|
doOnException(Throwable exception)
Allows subclasses to add behavior to run after exception in actor's body |
protected void
|
doOnInterrupt(InterruptedException exception)
Allows subclasses to add behavior to run after actor's interruption |
protected void
|
doOnStart()
Allows subclasses to add behavior to run after actor's start |
protected void
|
doOnTermination()
Allows subclasses to add behavior to run after actor's termination |
protected void
|
doOnTimeout()
Allows subclasses to add behavior to run after actor's timeout |
PGroup
|
getActorGroup()
Retrieves the group to which the actor belongs |
boolean
|
isActive()
Checks the current status of the Actor. |
boolean
|
isActorThread()
Checks whether the current thread is the actor's current thread. |
protected void
|
loop(Runnable code)
Ensures that the supplied closure will be invoked repeatedly in a loop. |
protected ActorMessage
|
pollMessage()
Polls a message from the queues |
protected void
|
react(groovy.time.Duration duration, groovy.lang.Closure code)
Schedules an ActorAction to take the next message off the message queue and to pass it on to the supplied closure. |
protected void
|
react(groovy.lang.Closure code)
Schedules an ActorAction to take the next message off the message queue and to pass it on to the supplied closure. |
protected void
|
react(long timeout, TimeUnit timeUnit, groovy.lang.Closure code)
Schedules an ActorAction to take the next message off the message queue and to pass it on to the supplied closure. |
protected void
|
react(long timeout, groovy.lang.Closure code)
Schedules an ActorAction to take the next message off the message queue and to pass it on to the supplied closure. |
void
|
run()
|
protected void
|
scheduleLoop()
|
MessageStream
|
send(Object message)
|
void
|
setActorGroup(PGroup group)
Sets the actor's group. |
SequentialProcessingActor
|
start()
Starts the Actor. |
Actor
|
stop()
Send message to stop to the actor. |
protected ActorMessage
|
takeMessage()
Takes a message from the queues. |
protected ActorMessage
|
takeMessage(long timeout, TimeUnit timeUnit)
Takes a message from the queues. |
Actor
|
terminate()
Terminate the Actor. |
Field Detail |
---|
protected static final int S_ACTIVE_MASK
protected static final int S_FINISHED_MASK
protected static final int S_FINISHING_MASK
protected static final int S_NOT_STARTED
protected static final int S_RUNNING
protected static final int S_STOPPED
protected static final int S_STOPPING
protected static final int S_STOP_TERMINATE_MASK
protected static final int S_TERMINATED
protected static final int S_TERMINATING
protected PGroup actorGroup
protected Runnable loopCode
protected int stopFlag
protected static final AtomicIntegerFieldUpdater stopFlagUpdater
Constructor Detail |
---|
protected SequentialProcessingActor()
Method Detail |
---|
protected final void checkStopTerminate()
protected void doOnException(Throwable exception)
exception
- The exception that was fired
protected void doOnInterrupt(InterruptedException exception)
exception
- The InterruptedException
protected void doOnStart()
protected void doOnTermination()
protected void doOnTimeout()
public PGroup getActorGroup()
@Override public final boolean isActive()
@Override public final boolean isActorThread()
protected final void loop(Runnable code)
code
- The closure to invoke repeatedly
protected final ActorMessage pollMessage()
protected final void react(groovy.time.Duration duration, groovy.lang.Closure code)
duration
- Time to wait at most for a message to arrive. The actor terminates if a message doesn't arrive within the given timeout.
The TimeCategory DSL to specify timeouts must be enabled explicitly inside the Actor's act() method.code
- The code to handle the next message. The reply() and replyIfExists() methods are available inside
the closure to send a reply back to the actor, which sent the original message.
protected final void react(groovy.lang.Closure code)
code
- The code to handle the next message. The reply() and replyIfExists() methods are available inside
the closure to send a reply back to the actor, which sent the original message.
protected final void react(long timeout, TimeUnit timeUnit, groovy.lang.Closure code)
timeout
- Time in milliseconds to wait at most for a message to arrive. The actor terminates if a message doesn't arrive within the given timeout.timeUnit
- a TimeUnit determining how to interpret the timeout parametercode
- The code to handle the next message. The reply() and replyIfExists() methods are available inside
the closure to send a reply back to the actor, which sent the original message.
protected final void react(long timeout, groovy.lang.Closure code)
timeout
- Time in milliseconds to wait at most for a message to arrive. The actor terminates if a message doesn't arrive within the given timeout.code
- The code to handle the next message. The reply() and replyIfExists() methods are available inside
the closure to send a reply back to the actor, which sent the original message.
@SuppressWarnings({"ThrowCaughtLocally"}) public void run()
protected void scheduleLoop()
@Override public final MessageStream send(Object message)
public final void setActorGroup(PGroup group)
group
- new group
@Override public final SequentialProcessingActor start()
@Override public final Actor stop()
protected final ActorMessage takeMessage()
protected ActorMessage takeMessage(long timeout, TimeUnit timeUnit)
timeout
- Max time to wait for a messagetimeUnit
- The units for the timeout
@Override public final Actor terminate()
Groovy Documentation