Groovy Documentation

gpars.actor.impl
[Java] Class ReceivingMessageStream

java.lang.Object
  groovyx.gpars.serial.WithSerialId
      gpars.actor.impl.MessageStream
          gpars.actor.impl.ReceivingMessageStream

@SuppressWarnings({"ThrowableInstanceNeverThrown"})
public abstract class ReceivingMessageStream
extends MessageStream

Authors:
Alex Tkachman, Vaclav Pech


Nested Class Summary
static class ReceivingMessageStream.ReplyCategory

Enhances objects with the ability to send replies and detect message originators.

 
Field Summary
protected WeakHashMap obj2Sender

 
Method Summary
protected List getSenders()

protected Object receive()

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

protected Object receive(long timeout, TimeUnit units)

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

protected Object receive(groovy.time.BaseDuration duration)

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

protected Object receiveImpl()

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

protected Object receiveImpl(long timeout, TimeUnit units)

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

protected void reply(Object message)

Sends a reply to all currently processed messages.

protected void replyIfExists(Object message)

Sends a reply to all currently processed messages, which have been sent by an actor.

 
Methods inherited from class MessageStream
call, getRemoteClass, leftShift, send, send, send, sendAndContinue, sendAndWait, sendAndWait, sendAndWait
 

Field Detail

obj2Sender

protected final WeakHashMap obj2Sender


 
Method Detail

getSenders

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


receive

protected final Object receive()
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, or null, if the timeout expires.


receive

protected final Object receive(long timeout, TimeUnit units)
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.


receive

protected final Object receive(groovy.time.BaseDuration duration)
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:
duration - how long to wait before giving up, in units of unit
Returns:
The message retrieved from the queue, or null, if the timeout expires.


receiveImpl

protected 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.
Returns:
The message retrieved from the queue, or null, if the timeout expires.


receiveImpl

protected Object receiveImpl(long timeout, TimeUnit units)
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.


reply

protected final void reply(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(). Calling reply()/replyIfExist() on the actor with disabled replying (through the disableSendingReplies() method) will result in IllegalStateException being thrown. Sending replies is enabled by default.
throws:
groovyx.gpars.actor.impl.ActorReplyException If some of the replies failed to be sent.
Parameters:
message - reply message


replyIfExists

protected final void replyIfExists(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. Calling reply()/replyIfExist() on the actor with disabled replying (through the disableSendingReplies() method) will result in IllegalStateException being thrown. Sending replies is enabled by default.
Parameters:
message - reply message


 

Groovy Documentation