org.codehaus.gpars

groovyx.gpars.actor.impl
Class ReplyingMessageStream

java.lang.Object
  groovyx.gpars.serial.WithSerialId
      groovyx.gpars.actor.impl.MessageStream
          groovyx.gpars.actor.Actor
              groovyx.gpars.actor.impl.ReplyingMessageStream

@SuppressWarnings({"ThrowableInstanceNeverThrown"})
class ReplyingMessageStream
extends Actor

Authors:
Alex Tkachman, Vaclav Pech


Field Summary
protected java.util.WeakHashMap obj2Sender

private java.util.List senders

A list of senders for the currently processed messages

private static long serialVersionUID

 
Fields inherited from class Actor
ACTOR_HAS_ALREADY_BEEN_STARTED, START_MESSAGE, STOP_MESSAGE, TERMINATE_MESSAGE, TIMEOUT_MESSAGE, currentThread, parallelGroup, timer
 
Constructor Summary
ReplyingMessageStream()

 
Method Summary
protected MessageStream getSender()

Retrieves the sender actor of the currently processed message.

protected java.util.List getSenders()

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.

protected void runEnhancedWithRepliesOnMessages(ActorMessage message, groovy.lang.Closure code)

 
Methods inherited from class Actor
createActorMessage, createRemoteHandle, deregisterCurrentActorWithThread, getJoinLatch, getParallelGroup, handleException, handleInterrupt, handleStart, handleTermination, handleTimeout, hasBeenStopped, isActive, isActorThread, join, join, join, join, onStop, registerCurrentActorWithThread, sendAndContinue, 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

obj2Sender

protected final java.util.WeakHashMap obj2Sender


senders

private final java.util.List senders
A list of senders for the currently processed messages


serialVersionUID

private static final long serialVersionUID


 
Constructor Detail

ReplyingMessageStream

ReplyingMessageStream()


 
Method Detail

getSender

protected final MessageStream getSender()
Retrieves the sender actor of the currently processed message.
throws:
groovyx.gpars.actor.impl.ActorReplyException If some of the replies failed to be sent.
Returns:
The sender of the currently processed message or null, if the message was not sent by an actor


getSenders

@SuppressWarnings({"ReturnOfCollectionOrArrayField"})
protected final java.util.List getSenders()


reply

protected final void reply(java.lang.Object message)
Sends a reply to all currently processed messages. Throws ActorReplyException if some messages have not been sent by an actor. For such cases use replyIfExists().
throws:
groovyx.gpars.actor.impl.ActorReplyException If some of the replies failed to be sent.
Parameters:
message - reply message


replyIfExists

protected final void replyIfExists(java.lang.Object message)
Sends a reply to all currently processed messages, which have been sent by an actor. Ignores potential errors when sending the replies, like no sender or sender already stopped.
Parameters:
message - reply message


runEnhancedWithRepliesOnMessages

@SuppressWarnings({"rawtypes", "RawUseOfParameterizedType"})
protected final void runEnhancedWithRepliesOnMessages(ActorMessage message, groovy.lang.Closure code)


 

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