org.codehaus.gpars

groovyx.gpars.actor
[Java] Class BlockingActor

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
                      groovyx.gpars.actor.BlockingActor

@java.lang.SuppressWarnings* @param message The original message
public abstract class BlockingActor
extends SequentialProcessingActor

Authors:
Vaclav Pech, Alex Tkachman, Dierk Koenig


Field Summary
static java.lang.String AN_ACTOR_CAN_ONLY_RECEIVE_ONE_MESSAGE_AT_A_TIME

private static java.lang.String THE_ACTOR_HAS_BEEN_STOPPED

private static java.lang.String THE_ACTOR_HAS_NOT_BEEN_STARTED

private static long serialVersionUID

 
Fields inherited from class SequentialProcessingActor
SHOULD_NOT_REACH_HERE, S_ACTIVE_MASK, S_FINISHED_MASK, S_FINISHING_MASK, S_NOT_STARTED, S_RUNNING, S_STOPPED, S_STOPPING, S_STOP_TERMINATE_MASK, S_TERMINATED, S_TERMINATING, inputQueue, inputQueueUpdater, ongoingThreadTermination, outputQueue, serialVersionUID, stopFlag, stopFlagUpdater, waitingThread
 
Fields inherited from class ReplyingMessageStream
sender, serialVersionUID
 
Fields inherited from class Actor
ACTOR_HAS_ALREADY_BEEN_STARTED, AFTER_START, CANNOT_SEND_REPLIES_NO_SENDER_HAS_BEEN_REGISTERED, EMPTY_ARGUMENTS, ON_DELIVERY_ERROR, RESPONDS_TO, START_MESSAGE, STOP_MESSAGE, TERMINATE_MESSAGE, TIMEOUT, TIMEOUT_MESSAGE, currentActorPerThread, currentThread, joinLatch, onStop, parallelGroup, serialVersionUID, timer
 
Fields inherited from class MessageStream
serialVersionUID
 
Fields inherited from class WithSerialId
serialHandle, serialVersionUID
 
Constructor Summary
BlockingActor()

 
Method Summary
private void checkStoppedFlags()

private java.lang.Object enhanceAndUnwrap(ActorMessage message)

private void enhanceReplies(ActorMessage message)

Retrieves a message from the message queue, waiting, if necessary, for a message to arrive.

protected void handleStart()

protected void receive(groovy.lang.Closure handler)

protected void receive(long timeout, java.util.concurrent.TimeUnit timeUnit, groovy.lang.Closure handler)

Retrieves a message from the message queue, waiting, if necessary, for a message to arrive.

protected void receive(groovy.time.Duration duration, groovy.lang.Closure handler)

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)

 
Methods inherited from class SequentialProcessingActor
act, awaitNextMessage, checkStopTerminate, handleTermination, hasBeenStopped, isActive, pollMessage, receive, receive, receive, receiveImpl, receiveImpl, retrieveNextMessage, run, send, setParallelGroup, silentStart, start, stop, sweepNextMessage, takeMessage, takeMessage, terminate, throwIfNeeded, transferQueues, unwrapMessage
 
Methods inherited from class ReplyingMessageStream
getSender, reply, replyIfExists, setSender
 
Methods inherited from class Actor
callDynamic, createActorMessage, createRemoteHandle, deregisterCurrentActorWithThread, getJoinLatch, getParallelGroup, handleException, handleInterrupt, handleStart, handleTermination, handleTimeout, hasBeenStopped, isActive, isActorThread, join, join, join, join, onStop, registerCurrentActorWithThread, sendAndContinue, sendAndPromise, setParallelGroup, silentStart, start, stop, sweepNextMessage, sweepQueue, terminate, threadBoundActor
 
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

AN_ACTOR_CAN_ONLY_RECEIVE_ONE_MESSAGE_AT_A_TIME

public static final java.lang.String AN_ACTOR_CAN_ONLY_RECEIVE_ONE_MESSAGE_AT_A_TIME


THE_ACTOR_HAS_BEEN_STOPPED

private static final java.lang.String THE_ACTOR_HAS_BEEN_STOPPED


THE_ACTOR_HAS_NOT_BEEN_STARTED

private static final java.lang.String THE_ACTOR_HAS_NOT_BEEN_STARTED


serialVersionUID

private static final long serialVersionUID


 
Constructor Detail

BlockingActor

BlockingActor()


 
Method Detail

checkStoppedFlags

private void checkStoppedFlags()


enhanceAndUnwrap

private java.lang.Object enhanceAndUnwrap(ActorMessage message)


enhanceReplies

private void enhanceReplies(ActorMessage message)
Retrieves a message from the message queue, waiting, if necessary, for a message to arrive.
throws:
InterruptedException If the thread is interrupted during the wait. Should propagate up to stop the thread.
Returns:
The message retrieved from the queue.


handleStart

@java.lang.Override
protected void handleStart()


receive

@java.lang.SuppressWarningshandler.call();
protected final void receive(groovy.lang.Closure handler)


receive

protected final void receive(long timeout, java.util.concurrent.TimeUnit timeUnit, groovy.lang.Closure handler)
Retrieves a message from the message queue, waiting, if necessary, for a message to arrive. The message retrieved from the queue is passed into the handler as the only parameter. A null value is passed into the handler, if the timeout expires
throws:
InterruptedException If the thread is interrupted during the wait. Should propagate up to stop the thread.
Parameters:
timeout - how long to wait before giving up, in units of unit
timeUnit - a TimeUnit determining how to interpret the timeout parameter
handler - A closure accepting the retrieved message as a parameter, which will be invoked after a message is received.


receive

@java.lang.SuppressWarnings
protected final void receive(groovy.time.Duration duration, groovy.lang.Closure handler)
Retrieves a message from the message queue, waiting, if necessary, for a message to arrive. The message retrieved from the queue is passed into the handler as the only parameter. A null value is passed into the handler, if the timeout expires
throws:
InterruptedException If the thread is interrupted during the wait. Should propagate up to stop the thread.
Parameters:
duration - how long to wait before giving up, in units of unit
handler - A closure accepting the retrieved message as a parameter, which will be invoked after a message is received.


receiveImpl

@java.lang.Override
protected final java.lang.Object receiveImpl()
Retrieves a message from the message queue, waiting, if necessary, for a message to arrive.
throws:
InterruptedException If the thread is interrupted during the wait. Should propagate up to stop the thread.
Parameters:
timeout - how long to wait before giving up, in units of unit
units - a TimeUnit determining how to interpret the timeout parameter
Returns:
The message retrieved from the queue, or null, if the timeout expires.


receiveImpl

@java.lang.Overrideprivate void checkStoppedFlags() {
protected final java.lang.Object receiveImpl(long timeout, java.util.concurrent.TimeUnit units)


 

Copyright © 2008–2013 Václav Pech. All Rights Reserved.