Groovy Documentation

gpars.actor.impl
[Java] Class MessageStream

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

public abstract class MessageStream
extends WithSerialId

Stream of abstract messages

Authors:
Alex Tkachman, Vaclav Pech, Dierk Koenig


Nested Class Summary
static class MessageStream.RemoteMessageStream

static class MessageStream.SendTo

 
Method Summary
MessageStream call(Object message)

Same as send

Class getRemoteClass()

MessageStream leftShift(Object message)

Same as send

MessageStream send(Object message)

Send message to stream and return immediately

MessageStream send()

Convenience method for send(new Object()).

MessageStream send(Object message, MessageStream replyTo)

Send message to stream and return immediately.

MessageStream sendAndContinue(Object message, groovy.lang.Closure closure)

Sends a message and execute continuation when reply became available.

Object sendAndWait(Object message)

Sends a message and waits for a reply.

Object sendAndWait(Object message, long timeout, TimeUnit units)

Sends a message and waits for a reply.

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

Sends a message and waits for a reply.

 

Method Detail

call

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


getRemoteClass

@Override
public Class getRemoteClass()


leftShift

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


send

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


send

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


send

public final MessageStream send(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


sendAndContinue

@SuppressWarnings({"AssignmentToMethodParameter"})
public final MessageStream sendAndContinue(Object message, groovy.lang.Closure closure)
Sends a message and execute continuation when reply became available.
throws:
InterruptedException if interrupted while waiting
Parameters:
message - message to send
closure - closure to execute when reply became available
Returns:
The message that came in reply to the original send.


sendAndWait

public final Object sendAndWait(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 Object sendAndWait(Object message, long timeout, 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 Object sendAndWait(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.


 

Groovy Documentation