Groovy Documentation

gpars.actor.impl
Class MessageStream

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

class MessageStream
extends WithSerialId

Stream of abstract messages

author:
Alex Tkachman, Vaclav Pech, Dierk Koenig


Nested Class Summary
class MessageStream.RemoteMessageStream

class MessageStream.ResultWaiter

Represents a pending request for a reply from an actor.

class MessageStream.SendTo

 
Constructor Summary
MessageStream()

 
Method Summary
MessageStream call(T message)

Same as send

Class getRemoteClass()

MessageStream leftShift(T message)

Same as send

static void reInterrupt()

MessageStream send(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.

MessageStream sendAndContinue(T message, Closure closure)

Sends a message and execute continuation when reply became available.

V sendAndWait(T message)

Sends a message and waits for a reply.

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

Sends a message and waits for a reply.

Object sendAndWait(T message, Duration duration)

Sends a message and waits for a reply.

 

Constructor Detail

MessageStream

MessageStream()


 
Method Detail

call

public final MessageStream call(T message)
Same as send
param:
message to send
return:
original stream


getRemoteClass

@Override
public Class getRemoteClass()


leftShift

public final MessageStream leftShift(T message)
Same as send
param:
message to send
return:
original stream


reInterrupt

public static void reInterrupt()


send

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


send

public MessageStream send()
Convenience method for send(new Object()).
return:
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.
param:
message message to send
param:
replyTo where to send reply
param:
type of message accepted by the stream
return:
always return message stream itself


sendAndContinue

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


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.
param:
message message to send
return:
The message that came in reply to the original send.
throws:
InterruptedException if interrupted while waiting


sendAndWait

public final Object sendAndWait(T 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.
param:
message message to send
param:
timeout timeout
param:
units units
return:
The message that came in reply to the original send.
throws:
InterruptedException if interrupted while waiting


sendAndWait

public final Object sendAndWait(T message, 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.
param:
message message to send
param:
duration timeout
return:
The message that came in reply to the original send.
throws:
InterruptedException if interrupted while waiting


 

Groovy Documentation