|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object groovyx.gpars.serial.WithSerialId groovyx.gpars.actor.impl.MessageStream groovyx.gpars.actor.Actor groovyx.gpars.actor.AbstractLoopingActor
public abstract class AbstractLoopingActor
Wraps all actors that repeatedly loop through incoming messages and hold no implicit state between subsequent messages.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class groovyx.gpars.actor.Actor |
---|
Actor.MyRemoteHandle, Actor.RemoteActor |
Nested classes/interfaces inherited from class groovyx.gpars.actor.impl.MessageStream |
---|
MessageStream.RemoteMessageStream, MessageStream.SendTo |
Field Summary | |
---|---|
private AsyncMessagingCore |
core
Holds the particular instance of async messaging core to use |
private MessageStream |
currentSender
|
private ActorTimerTask |
currentTimerTask
|
private static long |
serialVersionUID
|
private boolean |
stoppedFlag
|
private boolean |
terminatedFlag
|
(package private) boolean |
terminatingFlag
|
private int |
timeoutCounter
|
Fields inherited from class groovyx.gpars.actor.Actor |
---|
ACTOR_HAS_ALREADY_BEEN_STARTED, CANNOT_SEND_REPLIES_NO_SENDER_HAS_BEEN_REGISTERED, currentThread, parallelGroup, START_MESSAGE, STOP_MESSAGE, TERMINATE_MESSAGE, TIMEOUT, TIMEOUT_MESSAGE, timer |
Fields inherited from class groovyx.gpars.serial.WithSerialId |
---|
serialHandle |
Constructor Summary | |
---|---|
AbstractLoopingActor()
|
Method Summary | |
---|---|
private void |
cancelCurrentTimeoutTask()
|
private Actor |
doStart()
|
(package private) AsyncMessagingCore |
getCore()
|
protected MessageStream |
getSender()
Retrieves the sender actor of the currently processed message. |
protected boolean |
hasBeenStopped()
|
protected void |
initialize(groovy.lang.Closure code)
Builds the async messaging core using the supplied code handler |
boolean |
isActive()
Checks the current status of the Actor. |
boolean |
isFair()
Retrieves the actor's fairness flag Fair actors give up the thread after processing each message, non-fair actors keep a thread until their message queue is empty. |
void |
makeFair()
Makes the actor fair. |
protected void |
reply(java.lang.Object message)
Sends a reply to all currently processed messages. |
protected void |
replyIfExists(java.lang.Object message)
Sends a reply to all currently processed messages, which have been sent by an actor. |
private void |
runEnhancedWithoutRepliesOnMessages(ActorMessage message,
groovy.lang.Closure code,
java.lang.Object arguments)
|
MessageStream |
send(java.lang.Object message)
Send message to stream and return immediately |
void |
setParallelGroup(PGroup group)
Sets the parallel group. |
protected void |
setTimeout(long timeout)
|
Actor |
silentStart()
Starts the Actor without sending the START_MESSAGE message to speed the start-up. |
Actor |
start()
Starts the Actor and sends it the START_MESSAGE to run any afterStart handlers. |
Actor |
stop()
Send message to stop to the Actor. |
protected ActorMessage |
sweepNextMessage()
Removes the head of the message queue |
Actor |
terminate()
Terminates the Actor. |
Methods inherited from class groovyx.gpars.actor.Actor |
---|
createActorMessage, createRemoteHandle, deregisterCurrentActorWithThread, getJoinLatch, getParallelGroup, handleException, handleInterrupt, handleStart, handleTermination, handleTimeout, isActorThread, join, join, join, join, onStop, registerCurrentActorWithThread, sendAndContinue, sendAndPromise, sweepQueue, threadBoundActor |
Methods inherited from class groovyx.gpars.actor.impl.MessageStream |
---|
call, getRemoteClass, leftShift, send, send, sendAndWait, sendAndWait, sendAndWait |
Methods inherited from class groovyx.gpars.serial.WithSerialId |
---|
getOrCreateSerialHandle, writeReplace |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final long serialVersionUID
private volatile boolean stoppedFlag
private volatile boolean terminatedFlag
volatile boolean terminatingFlag
private ActorTimerTask currentTimerTask
private int timeoutCounter
private MessageStream currentSender
private AsyncMessagingCore core
Constructor Detail |
---|
public AbstractLoopingActor()
Method Detail |
---|
final AsyncMessagingCore getCore()
protected final void initialize(groovy.lang.Closure code)
code
- Code to run on each messagepublic final boolean isFair()
public final void makeFair()
protected final void setTimeout(long timeout)
private void cancelCurrentTimeoutTask()
public Actor silentStart()
silentStart
in class Actor
public Actor start()
start
in class Actor
private Actor doStart()
public final Actor stop()
Actor
stop
in class Actor
public final Actor terminate()
Actor
terminate
in class Actor
public final boolean isActive()
Actor
isActive
in class Actor
protected final boolean hasBeenStopped()
hasBeenStopped
in class Actor
protected ActorMessage sweepNextMessage()
sweepNextMessage
in class Actor
public MessageStream send(java.lang.Object message)
MessageStream
send
in class MessageStream
message
- message to send
public void setParallelGroup(PGroup group)
Actor
setParallelGroup
in class Actor
group
- new groupprotected final MessageStream getSender()
ActorReplyException
- If some of the replies failed to be sent.protected final void reply(java.lang.Object message)
message
- reply message
ActorReplyException
- If some of the replies failed to be sent.protected final void replyIfExists(java.lang.Object message)
message
- reply messageprivate void runEnhancedWithoutRepliesOnMessages(ActorMessage message, groovy.lang.Closure code, java.lang.Object arguments)
|
Copyright © 2008–2012 Václav Pech. All Rights Reserved. | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |