|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectgroovyx.gpars.serial.WithSerialId
groovyx.gpars.actor.impl.MessageStream
groovyx.gpars.actor.Actor
groovyx.gpars.actor.impl.ReplyingMessageStream
groovyx.gpars.actor.impl.SequentialProcessingActor
@Deprecated public abstract class SequentialProcessingActor
Nested Class Summary | |
---|---|
private class |
SequentialProcessingActor.MultiMessageReaction
Deprecated. Enables multiple argument closures to be passed to react(). |
private static class |
SequentialProcessingActor.Node
Deprecated. Represents an element in the message queue. |
private static class |
SequentialProcessingActor.Reaction
Deprecated. Buffers messages for the next continuation of an event-driven actor, handles timeouts and no-param continuations. |
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 | |
---|---|
protected groovy.lang.Closure |
afterLoopCode
Deprecated. |
private int |
count
Deprecated. Counter of messages in the queues |
private static java.util.concurrent.atomic.AtomicIntegerFieldUpdater<SequentialProcessingActor> |
countUpdater
Deprecated. |
private static java.lang.String |
ERROR_EVALUATING_LOOP_CONDITION
Deprecated. |
private SequentialProcessingActor.Node |
inputQueue
Deprecated. Stored incoming messages. |
private static java.util.concurrent.atomic.AtomicReferenceFieldUpdater<SequentialProcessingActor,SequentialProcessingActor.Node> |
inputQueueUpdater
Deprecated. |
protected java.lang.Runnable |
loopCode
Deprecated. Code for the loop, if any |
protected java.util.concurrent.Callable<java.lang.Boolean> |
loopCondition
Deprecated. |
private static ActorMessage |
loopMessage
Deprecated. |
private java.util.concurrent.atomic.AtomicBoolean |
ongoingThreadTermination
Deprecated. |
private SequentialProcessingActor.Node |
outputQueue
Deprecated. Stores messages ready for processing by the actor. |
private SequentialProcessingActor.Reaction |
reaction
Deprecated. Code for the next action |
protected static int |
S_ACTIVE_MASK
Deprecated. |
protected static int |
S_FINISHED_MASK
Deprecated. |
protected static int |
S_FINISHING_MASK
Deprecated. |
protected static int |
S_NOT_STARTED
Deprecated. |
protected static int |
S_RUNNING
Deprecated. |
protected static int |
S_STOP_TERMINATE_MASK
Deprecated. |
protected static int |
S_STOPPED
Deprecated. |
protected static int |
S_STOPPING
Deprecated. |
protected static int |
S_TERMINATED
Deprecated. |
protected static int |
S_TERMINATING
Deprecated. |
private static long |
serialVersionUID
Deprecated. |
private static java.lang.String |
SHOULD_NOT_REACH_HERE
Deprecated. |
private static ActorMessage |
startMessage
Deprecated. |
protected int |
stopFlag
Deprecated. Indicates whether the actor should terminate |
protected static java.util.concurrent.atomic.AtomicIntegerFieldUpdater<SequentialProcessingActor> |
stopFlagUpdater
Deprecated. |
private java.lang.Thread |
waitingThread
Deprecated. |
Fields inherited from class groovyx.gpars.actor.impl.ReplyingMessageStream |
---|
obj2Sender |
Fields inherited from class groovyx.gpars.actor.Actor |
---|
ACTOR_HAS_ALREADY_BEEN_STARTED, currentThread, parallelGroup, START_MESSAGE, STOP_MESSAGE, TERMINATE_MESSAGE, TIMEOUT, TIMEOUT_MESSAGE, timer |
Fields inherited from class groovyx.gpars.serial.WithSerialId |
---|
serialHandle |
Constructor Summary | |
---|---|
protected |
SequentialProcessingActor()
Deprecated. Creates a new instance, sets the default actor group. |
Method Summary | |
---|---|
private ActorMessage |
awaitNextMessage(long endTime)
Deprecated. Holds common functionality for takeMessage() methods. |
private void |
doLoopCall()
Deprecated. |
private ActorMessage |
getMessage()
Deprecated. Retrieves the next message from the queue |
protected void |
handleTermination()
Deprecated. |
protected boolean |
hasBeenStopped()
Deprecated. |
protected void |
checkStopTerminate()
Deprecated. |
boolean |
isActive()
Deprecated. Checks the current status of the Actor. |
private void |
loop(java.util.concurrent.Callable<java.lang.Boolean> condition,
groovy.lang.Closure afterLoopCode,
java.lang.Runnable code)
Deprecated. Ensures that the supplied closure will be invoked repeatedly in a loop. |
protected void |
loop(groovy.lang.Closure condition,
groovy.lang.Closure afterLoopCode,
java.lang.Runnable code)
Deprecated. Ensures that the supplied closure will be invoked repeatedly in a loop. |
protected void |
loop(groovy.lang.Closure condition,
java.lang.Runnable code)
Deprecated. Ensures that the supplied closure will be invoked repeatedly in a loop. |
protected void |
loop(int numberOfLoops,
groovy.lang.Closure afterLoopCode,
java.lang.Runnable code)
Deprecated. Ensures that the supplied closure will be invoked repeatedly in a loop. |
protected void |
loop(int numberOfLoops,
java.lang.Runnable code)
Deprecated. Ensures that the supplied closure will be invoked repeatedly in a loop. |
protected void |
loop(java.lang.Runnable code)
Deprecated. Ensures that the supplied closure will be invoked repeatedly in a loop. |
protected ActorMessage |
pollMessage()
Deprecated. Polls a message from the queues |
protected void |
react(groovy.lang.Closure code)
Deprecated. 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.time.Duration duration,
groovy.lang.Closure code)
Deprecated. 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)
Deprecated. 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,
java.util.concurrent.TimeUnit timeUnit,
groovy.lang.Closure code)
Deprecated. Schedules an ActorAction to take the next message off the message queue and to pass it on to the supplied closure. |
protected java.lang.Object |
receive()
Deprecated. Retrieves a message from the message queue, waiting, if necessary, for a message to arrive. |
protected java.lang.Object |
receive(groovy.time.BaseDuration duration)
Deprecated. Retrieves a message from the message queue, waiting, if necessary, for a message to arrive. |
protected java.lang.Object |
receive(long timeout,
java.util.concurrent.TimeUnit units)
Deprecated. Retrieves a message from the message queue, waiting, if necessary, for a message to arrive. |
protected abstract java.lang.Object |
receiveImpl()
Deprecated. Retrieves a message from the message queue, waiting, if necessary, for a message to arrive. |
protected abstract java.lang.Object |
receiveImpl(long timeout,
java.util.concurrent.TimeUnit units)
Deprecated. Retrieves a message from the message queue, waiting, if necessary, for a message to arrive. |
private ActorMessage |
retrieveNextMessage()
Deprecated. Takes the next message from the outputQueue, decrements the counter and possibly throws control exceptions |
void |
run()
Deprecated. |
(package private) void |
runReaction(ActorMessage message,
groovy.lang.Closure code)
Deprecated. |
MessageStream |
send(java.lang.Object message)
Deprecated. Send message to stream and return immediately |
void |
setParallelGroup(groovyx.gpars.group.PGroup group)
Deprecated. Sets the actor's group. |
private void |
schedule()
Deprecated. Schedules the current actor for processing on the actor group's thread pool. |
protected void |
scheduleLoop()
Deprecated. |
Actor |
silentStart()
Deprecated. Starts the Actor without sending the START_MESSAGE message to speed the start-up. |
SequentialProcessingActor |
start()
Deprecated. Starts the Actor. |
Actor |
stop()
Deprecated. Send message to stop to the actor. |
protected ActorMessage |
sweepNextMessage()
Deprecated. Removes the head of the message queue |
protected ActorMessage |
takeMessage()
Deprecated. Takes a message from the queues. |
protected ActorMessage |
takeMessage(long timeout,
java.util.concurrent.TimeUnit timeUnit)
Deprecated. Takes a message from the queues. |
Actor |
terminate()
Deprecated. Terminate the Actor. |
private void |
throwIfNeeded(ActorMessage toProcess)
Deprecated. Checks the supplied message and throws either STOP or TERMINATE, if the message is a Stop or Terminate message respectively. |
private void |
transferQueues()
Deprecated. Transfers messages from the input queue into the output queue, reverting the order of the elements. |
private static java.lang.Object |
unwrapMessage(java.lang.Object msg)
Deprecated. |
private static boolean |
verifyLoopCondition(java.util.concurrent.Callable<java.lang.Boolean> condition)
Deprecated. |
Methods inherited from class groovyx.gpars.actor.impl.ReplyingMessageStream |
---|
getSender, getSenders, reply, replyIfExists, runEnhancedWithRepliesOnMessages |
Methods inherited from class groovyx.gpars.actor.Actor |
---|
createActorMessage, createRemoteHandle, deregisterCurrentActorWithThread, getJoinLatch, getParallelGroup, handleException, handleInterrupt, handleStart, handleTimeout, isActorThread, join, join, join, join, onStop, registerCurrentActorWithThread, sendAndContinue, threadBoundActor |
Methods inherited from class groovyx.gpars.actor.impl.MessageStream |
---|
call, getRemoteClass, leftShift, reInterrupt, 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
protected java.lang.Runnable loopCode
protected groovy.lang.Closure afterLoopCode
protected java.util.concurrent.Callable<java.lang.Boolean> loopCondition
private volatile SequentialProcessingActor.Reaction reaction
private volatile SequentialProcessingActor.Node inputQueue
private SequentialProcessingActor.Node outputQueue
private final java.util.concurrent.atomic.AtomicBoolean ongoingThreadTermination
private volatile int count
private static final java.util.concurrent.atomic.AtomicReferenceFieldUpdater<SequentialProcessingActor,SequentialProcessingActor.Node> inputQueueUpdater
private static final java.util.concurrent.atomic.AtomicIntegerFieldUpdater<SequentialProcessingActor> countUpdater
private volatile java.lang.Thread waitingThread
private static final ActorMessage startMessage
private static final ActorMessage loopMessage
protected static final int S_ACTIVE_MASK
protected static final int S_FINISHING_MASK
protected static final int S_FINISHED_MASK
protected static final int S_STOP_TERMINATE_MASK
protected static final int S_NOT_STARTED
protected static final int S_RUNNING
protected static final int S_STOPPING
protected static final int S_TERMINATING
protected static final int S_STOPPED
protected static final int S_TERMINATED
protected volatile int stopFlag
protected static final java.util.concurrent.atomic.AtomicIntegerFieldUpdater<SequentialProcessingActor> stopFlagUpdater
private static final java.lang.String SHOULD_NOT_REACH_HERE
private static final java.lang.String ERROR_EVALUATING_LOOP_CONDITION
Constructor Detail |
---|
protected SequentialProcessingActor()
Method Detail |
---|
public final boolean isActive()
isActive
in class Actor
private ActorMessage getMessage()
private void throwIfNeeded(ActorMessage toProcess)
toProcess
- The next message to process by the actorsprotected final ActorMessage pollMessage()
protected final ActorMessage takeMessage() throws java.lang.InterruptedException
java.lang.InterruptedException
- If the thread gets interrupted.protected ActorMessage takeMessage(long timeout, java.util.concurrent.TimeUnit timeUnit) throws java.lang.InterruptedException
timeout
- Max time to wait for a messagetimeUnit
- The units for the timeout
java.lang.InterruptedException
- If the thread gets interrupted.private ActorMessage awaitNextMessage(long endTime) throws java.lang.InterruptedException
endTime
- End of the timeout, 0 if no timeout was set
java.lang.InterruptedException
- If the thread has been interruptedprivate ActorMessage retrieveNextMessage()
private void transferQueues()
public final void setParallelGroup(groovyx.gpars.group.PGroup group)
setParallelGroup
in class Actor
group
- new grouppublic final MessageStream send(java.lang.Object message)
MessageStream
send
in class MessageStream
message
- message to send
protected final boolean hasBeenStopped()
hasBeenStopped
in class Actor
private void schedule()
protected void scheduleLoop()
protected void handleTermination()
handleTermination
in class Actor
public Actor silentStart()
Actor
silentStart
in class Actor
public final SequentialProcessingActor start()
start
in class Actor
public final Actor stop()
stop
in class Actor
public final Actor terminate()
terminate
in class Actor
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, java.util.concurrent.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.protected abstract java.lang.Object receiveImpl() throws java.lang.InterruptedException
java.lang.InterruptedException
- If the thread is interrupted during the wait. Should propagate up to stop the thread.protected abstract java.lang.Object receiveImpl(long timeout, java.util.concurrent.TimeUnit units) throws java.lang.InterruptedException
timeout
- how long to wait before giving up, in units of unitunits
- a TimeUnit determining how to interpret the timeout parameter
java.lang.InterruptedException
- If the thread is interrupted during the wait. Should propagate up to stop the thread.protected final java.lang.Object receive() throws java.lang.InterruptedException
java.lang.InterruptedException
- If the thread is interrupted during the wait. Should propagate up to stop the thread.protected final java.lang.Object receive(long timeout, java.util.concurrent.TimeUnit units) throws java.lang.InterruptedException
timeout
- how long to wait before giving up, in units of unitunits
- a TimeUnit determining how to interpret the timeout parameter
java.lang.InterruptedException
- If the thread is interrupted during the wait. Should propagate up to stop the thread.private static java.lang.Object unwrapMessage(java.lang.Object msg)
protected final java.lang.Object receive(groovy.time.BaseDuration duration) throws java.lang.InterruptedException
duration
- how long to wait before giving up, in units of unit
java.lang.InterruptedException
- If the thread is interrupted during the wait. Should propagate up to stop the thread.protected final ActorMessage sweepNextMessage()
sweepNextMessage
in class Actor
public void run()
run
in interface java.lang.Runnable
protected final void loop(java.lang.Runnable code)
code
- The closure to invoke repeatedlyprotected final void loop(int numberOfLoops, java.lang.Runnable code)
numberOfLoops
- The loop will only be run the given number of timescode
- The closure to invoke repeatedlyprotected final void loop(int numberOfLoops, groovy.lang.Closure afterLoopCode, java.lang.Runnable code)
numberOfLoops
- The loop will only be run the given number of timesafterLoopCode
- Code to run after the main actor's loop finishescode
- The closure to invoke repeatedlyprotected final void loop(groovy.lang.Closure condition, java.lang.Runnable code)
condition
- A condition to evaluate before each iteration starts. If the condition returns false, the loop exits.code
- The closure to invoke repeatedlyprotected final void loop(groovy.lang.Closure condition, groovy.lang.Closure afterLoopCode, java.lang.Runnable code)
condition
- A condition to evaluate before each iteration starts. If the condition returns false, the loop exits.afterLoopCode
- Code to run after the main actor's loop finishescode
- The closure to invoke repeatedlyprivate void loop(java.util.concurrent.Callable<java.lang.Boolean> condition, groovy.lang.Closure afterLoopCode, java.lang.Runnable code)
condition
- A condition to evaluate before each iteration starts. If the condition returns false, the loop exits.afterLoopCode
- Code to run after the main actor's loop finishescode
- The closure to invoke repeatedlyprivate static boolean verifyLoopCondition(java.util.concurrent.Callable<java.lang.Boolean> condition)
private void doLoopCall()
final void runReaction(ActorMessage message, groovy.lang.Closure code)
protected final void checkStopTerminate()
|
Copyright © 2008–2010 Václav Pech. All Rights Reserved. | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |