org.codehaus.gpars

groovyx.gpars.actor.impl
[Java] Class MessageStream

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

public abstract class MessageStream
extends WithSerialId

Represents a stream of messages and forms the base class for actors

Authors:
Alex Tkachman, Vaclav Pech, Dierk Koenig


Nested Class Summary
static class MessageStream.RemoteMessageStream

private static class MessageStream.ResultWaiter

Represents a pending request for a reply from an actor.

static class MessageStream.SendTo

 
Field Summary
private static long serialVersionUID

 
Fields inherited from class WithSerialId
serialHandle, serialVersionUID
 
Constructor Summary
MessageStream()

 
Method Summary
MessageStream call(T message)

Same as send

java.lang.Class getRemoteClass()

MessageStream leftShift(T message)

Same as send

static void reInterrupt()

MessageStream send(java.lang.Object message)

Send message to stream and return immediately

MessageStream send()

Convenience method for send(new Object()).

MessageStream send(T message, MessageStream replyTo)

Send message to stream and return immediately.

V sendAndWait(T message)

Sends a message and waits for a reply.

java.lang.Object sendAndWait(T message, long timeout, java.util.concurrent.TimeUnit units)

Sends a message and waits for a reply.

java.lang.Object sendAndWait(T message, groovy.time.Duration duration)

Sends a message and waits for a reply.

 
Methods inherited from class WithSerialId
createRemoteHandle, getOrCreateSerialHandle, getRemoteClass, writeReplace
 
Methods inherited from class java.lang.Object
java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#wait(long, int), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll()
 

Field Detail

serialVersionUID

private static final long serialVersionUID


 
Constructor Detail

MessageStream

MessageStream()


 
Method Detail

call

public final MessageStream call(T message)
Same as send
Parameters:
message - to send
Returns:
original stream


getRemoteClass

@Override
@SuppressWarnings("unchecked")
public java.lang.Class getRemoteClass()


leftShift

public final MessageStream leftShift(T message)
Same as send
Parameters:
message - to send
Returns:
original stream


reInterrupt

static void reInterrupt()


send

public MessageStream send(java.lang.Object message)
Send message to stream and return immediately
Parameters:
message - message to send
Returns:
always return message stream itself


send

public final MessageStream send()
Convenience method for send(new Object()).
Returns:
always return message stream itself


send

public final MessageStream send(T message, MessageStream replyTo)
Send message to stream and return immediately. Allows to specify an arbitrary actor to send replies to. By default replies are sent to the originator (sender) of each message, however, when a different actor is specified as the optional second argument to the send() method, this supplied actor will receive the replies instead.
Parameters:
message - message to send
replyTo - where to send reply
- type of message accepted by the stream
Returns:
always return message stream itself


sendAndWait

public final V sendAndWait(T message)
Sends a message and waits for a reply. Returns the reply or throws an IllegalStateException, if the target actor cannot reply.
throws:
InterruptedException if interrupted while waiting
Parameters:
message - message to send
Returns:
The message that came in reply to the original send.


sendAndWait

public final java.lang.Object sendAndWait(T message, long timeout, java.util.concurrent.TimeUnit units)
Sends a message and waits for a reply. Timeouts after the specified timeout. In case of timeout returns null. Returns the reply or throws an IllegalStateException, if the target actor cannot reply.
throws:
InterruptedException if interrupted while waiting
Parameters:
message - message to send
timeout - timeout
units - units
Returns:
The message that came in reply to the original send.


sendAndWait

public final java.lang.Object sendAndWait(T message, groovy.time.Duration duration)
Sends a message and waits for a reply. Timeouts after the specified timeout. In case of timeout returns null. Returns the reply or throws an IllegalStateException, if the target actor cannot reply.
throws:
InterruptedException if interrupted while waiting
Parameters:
message - message to send
duration - timeout
Returns:
The message that came in reply to the original send.


 

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