Groovy Documentation

gpars.actor.impl
Class ReceivingMessageStream

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

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

author:
Alex Tkachman, Vaclav Pech


Nested Class Summary
class ReceivingMessageStream.ReplyCategory

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

 
Field Summary
protected WeakHashMap obj2Sender

 
Constructor Summary
ReceivingMessageStream()

 
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(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, reInterrupt, send, send, send, sendAndContinue, sendAndWait, sendAndWait, sendAndWait
 

Field Detail

obj2Sender

protected final WeakHashMap obj2Sender


 
Constructor Detail

ReceivingMessageStream

ReceivingMessageStream()


 
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.
return:
The message retrieved from the queue, or null, if the timeout expires.
throws:
InterruptedException If the thread is interrupted during the wait. Should propagate up to stop the thread.


receive

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


receive

protected final Object receive(BaseDuration duration)
Retrieves a message from the message queue, waiting, if necessary, for a message to arrive.
param:
duration how long to wait before giving up, in units of unit
return:
The message retrieved from the queue, or null, if the timeout expires.
throws:
InterruptedException If the thread is interrupted during the wait. Should propagate up to stop the thread.


receiveImpl

protected Object receiveImpl()
Retrieves a message from the message queue, waiting, if necessary, for a message to arrive.
return:
The message retrieved from the queue, or null, if the timeout expires.
throws:
InterruptedException If the thread is interrupted during the wait. Should propagate up to stop the thread.


receiveImpl

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


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.
param:
message reply message
throws:
groovyx.gpars.actor.impl.ActorReplyException If some of the replies failed to be sent.


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.
param:
message reply message


 

Groovy Documentation