|
org.codehaus.gpars | |||||||
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.impl.ReplyingMessageStream groovyx.gpars.actor.impl.SequentialProcessingActor
@SuppressWarnings({"UnqualifiedStaticUsage"}) public abstract class SequentialProcessingActor extends ReplyingMessageStream
Nested Class Summary | |
---|---|
private static class |
SequentialProcessingActor.Node
Represents an element in the message queue. |
Field Summary | |
---|---|
private static java.lang.String |
SHOULD_NOT_REACH_HERE
|
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
|
private SequentialProcessingActor.Node |
inputQueue
Stored incoming messages. |
private static java.util.concurrent.atomic.AtomicReferenceFieldUpdater |
inputQueueUpdater
|
private java.util.concurrent.atomic.AtomicBoolean |
ongoingThreadTermination
|
private SequentialProcessingActor.Node |
outputQueue
Stores messages ready for processing by the actor. |
private static long |
serialVersionUID
|
protected int |
stopFlag
Indicates whether the actor should terminate |
protected static java.util.concurrent.atomic.AtomicIntegerFieldUpdater |
stopFlagUpdater
|
private java.lang.Thread |
waitingThread
|
Fields inherited from class ReplyingMessageStream | |
---|---|
sender, serialVersionUID |
Fields inherited from class MessageStream | |
---|---|
serialVersionUID |
Fields inherited from class WithSerialId | |
---|---|
serialHandle, serialVersionUID |
Constructor Summary | |
protected SequentialProcessingActor()
Creates a new instance, sets the default actor group. |
Method Summary | |
---|---|
protected void
|
act()
This method represents the body of the actor. |
private ActorMessage
|
awaitNextMessage(long endTime)
Holds common functionality for takeMessage() methods. |
protected void
|
checkStopTerminate()
|
protected void
|
handleTermination()
|
protected boolean
|
hasBeenStopped()
|
boolean
|
isActive()
Checks the current status of the Actor. |
protected ActorMessage
|
pollMessage()
Polls a message from the queues |
protected java.lang.Object
|
receive()
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)
Retrieves a message from the message queue, waiting, if necessary, for a message to arrive. |
protected java.lang.Object
|
receive(groovy.time.BaseDuration duration)
Retrieves a message from the message queue, waiting, if necessary, for a message to arrive. |
protected java.lang.Object
|
receiveImpl()
Retrieves a message from the message queue, waiting, if necessary, for a message to arrive. |
protected java.lang.Object
|
receiveImpl(long timeout, java.util.concurrent.TimeUnit units)
Retrieves a message from the message queue, waiting, if necessary, for a message to arrive. |
private ActorMessage
|
retrieveNextMessage()
Takes the next message from the outputQueue, decrements the counter and possibly throws control exceptions |
void
|
run()
|
MessageStream
|
send(java.lang.Object message)
|
void
|
setParallelGroup(PGroup group)
Sets the actor's group. |
Actor
|
silentStart()
|
SequentialProcessingActor
|
start()
Starts the Actor. |
Actor
|
stop()
Send message to stop to the actor. |
protected ActorMessage
|
sweepNextMessage()
Removes the head of the message queue |
protected ActorMessage
|
takeMessage()
Takes a message from the queues. |
protected ActorMessage
|
takeMessage(long timeout, java.util.concurrent.TimeUnit timeUnit)
Takes a message from the queues. |
Actor
|
terminate()
Terminate the Actor. |
private void
|
throwIfNeeded(ActorMessage toProcess)
Checks the supplied message and throws either STOP or TERMINATE, if the message is a Stop or Terminate message respectively. |
private void
|
transferQueues()
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)
|
Methods inherited from class ReplyingMessageStream | |
---|---|
getSender, reply, replyIfExists, setSender |
Methods inherited from class MessageStream | |
---|---|
call, getRemoteClass, leftShift, reInterrupt, send, send, send, sendAndWait, sendAndWait, sendAndWait |
Methods inherited from class WithSerialId | |
---|---|
createRemoteHandle, getOrCreateSerialHandle, getRemoteClass, writeReplace |
Field Detail |
---|
private static final java.lang.String SHOULD_NOT_REACH_HERE
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
@SuppressWarnings({"UnusedDeclaration"}) //modified through inputQueryUpdater private SequentialProcessingActor.Node inputQueue
private static final java.util.concurrent.atomic.AtomicReferenceFieldUpdater inputQueueUpdater
private final java.util.concurrent.atomic.AtomicBoolean ongoingThreadTermination
private SequentialProcessingActor.Node outputQueue
private static final long serialVersionUID
protected int stopFlag
protected static final java.util.concurrent.atomic.AtomicIntegerFieldUpdater stopFlagUpdater
private java.lang.Thread waitingThread
Constructor Detail |
---|
protected SequentialProcessingActor()
Method Detail |
---|
protected void act()
private ActorMessage awaitNextMessage(long endTime)
endTime
- End of the timeout, 0 if no timeout was set
protected final void checkStopTerminate()
@Override protected void handleTermination()
@Override protected final boolean hasBeenStopped()
@Override public final boolean isActive()
protected final ActorMessage pollMessage()
protected final java.lang.Object receive()
protected final java.lang.Object receive(long timeout, java.util.concurrent.TimeUnit units)
timeout
- how long to wait before giving up, in units of unitunits
- a TimeUnit determining how to interpret the timeout parameter
protected final java.lang.Object receive(groovy.time.BaseDuration duration)
duration
- how long to wait before giving up, in units of unit
protected java.lang.Object receiveImpl()
protected java.lang.Object receiveImpl(long timeout, java.util.concurrent.TimeUnit units)
timeout
- how long to wait before giving up, in units of unitunits
- a TimeUnit determining how to interpret the timeout parameter
private ActorMessage retrieveNextMessage()
@Override @SuppressWarnings({"ThrowCaughtLocally", "OverlyLongMethod"}) public void run()
@Override public final MessageStream send(java.lang.Object message)
@Override public final void setParallelGroup(PGroup group)
group
- new group
@Override public Actor silentStart()
@Override public final SequentialProcessingActor start()
@Override public final Actor stop()
@Override protected final ActorMessage sweepNextMessage()
protected final ActorMessage takeMessage()
protected ActorMessage takeMessage(long timeout, java.util.concurrent.TimeUnit timeUnit)
timeout
- Max time to wait for a messagetimeUnit
- The units for the timeout
@Override public final Actor terminate()
private void throwIfNeeded(ActorMessage toProcess)
toProcess
- The next message to process by the actors
private void transferQueues()
private static java.lang.Object unwrapMessage(java.lang.Object msg)
Copyright © 2008–2012 Václav Pech. All Rights Reserved.