groovyx.gpars.actor.impl
Class MessageStream.ResultWaiter<V>

java.lang.Object
  extended by groovyx.gpars.serial.WithSerialId
      extended by groovyx.gpars.actor.impl.MessageStream
          extended by groovyx.gpars.actor.impl.MessageStream.ResultWaiter<V>
Type Parameters:
V - The type of expected reply message
All Implemented Interfaces:
java.io.Serializable
Enclosing class:
MessageStream

private static class MessageStream.ResultWaiter<V>
extends MessageStream

Represents a pending request for a reply from an actor.


Nested Class Summary
 
Nested classes/interfaces inherited from class groovyx.gpars.actor.impl.MessageStream
MessageStream.RemoteMessageStream, MessageStream.SendTo
 
Field Summary
private  boolean isSet
           
private static long serialVersionUID
           
private  java.lang.Object value
          Holds a reference to the calling thread, while waiting, and the received reply message, once it has arrived.
 
Fields inherited from class groovyx.gpars.serial.WithSerialId
serialHandle
 
Constructor Summary
private MessageStream.ResultWaiter()
           
 
Method Summary
 V getResult()
          Retrieves the response blocking until a message arrives
 java.lang.Object getResult(long timeout, java.util.concurrent.TimeUnit units)
          Retrieves the response blocking until a message arrives
 void onDeliveryError(java.lang.Object msg)
          Handle cases when the message sent to the actor doesn't get delivered
private  void rethrowException()
           
 MessageStream send(java.lang.Object message)
          Accepts the message as a reply and wakes up the sleeping thread.
 
Methods inherited from class groovyx.gpars.actor.impl.MessageStream
call, getRemoteClass, leftShift, reInterrupt, send, send, sendAndWait, sendAndWait, sendAndWait
 
Methods inherited from class groovyx.gpars.serial.WithSerialId
createRemoteHandle, getOrCreateSerialHandle, writeReplace
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

value

private volatile java.lang.Object value
Holds a reference to the calling thread, while waiting, and the received reply message, once it has arrived.


isSet

private volatile boolean isSet
Constructor Detail

MessageStream.ResultWaiter

private MessageStream.ResultWaiter()
Method Detail

send

public MessageStream send(java.lang.Object message)
Accepts the message as a reply and wakes up the sleeping thread.

Specified by:
send in class MessageStream
Parameters:
message - message to send
Returns:
this

getResult

public V getResult()
            throws java.lang.InterruptedException
Retrieves the response blocking until a message arrives

Returns:
The received message
Throws:
java.lang.InterruptedException - If the thread gets interrupted

getResult

public java.lang.Object getResult(long timeout,
                                  java.util.concurrent.TimeUnit units)
                           throws java.lang.InterruptedException
Retrieves the response blocking until a message arrives

Parameters:
timeout - How long to wait
units - Unit for the timeout
Returns:
The received message
Throws:
java.lang.InterruptedException - If the thread gets interrupted

rethrowException

private void rethrowException()

onDeliveryError

public void onDeliveryError(java.lang.Object msg)
Handle cases when the message sent to the actor doesn't get delivered

Parameters:
msg - The message that failed to get delivered

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