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(java.lang.Object message)

Same as send

java.lang.Class getRemoteClass()

MessageStream leftShift(java.lang.Object 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(java.lang.Object message, MessageStream replyTo)

Send message to stream and return immediately.

java.lang.Object sendAndWait(java.lang.Object message)

Sends a message and waits for a reply.

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

Sends a message and waits for a reply.

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

Sends a message and waits for a reply.

 
Methods inherited from class WithSerialId
createRemoteHandle, getOrCreateSerialHandle, getRemoteClass, writeReplace
 

Field Detail

serialVersionUID

private static final long serialVersionUID


 
Constructor Detail

MessageStream

MessageStream()


 
Method Detail

call

public final MessageStream call(java.lang.Object 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(java.lang.Object 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(java.lang.Object 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 java.lang.Object sendAndWait(java.lang.Object 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(java.lang.Object 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(java.lang.Object 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–2012 Václav Pech. All Rights Reserved.