Package co.paralleluniverse.actors
Class ActorRef<Message>
- java.lang.Object
-
- co.paralleluniverse.actors.ActorRef<Message>
-
- All Implemented Interfaces:
Port<Message>,PortAutoCloseable,SendPort<Message>,java.io.Serializable,java.lang.AutoCloseable
- Direct Known Subclasses:
ActorRefDelegate
public class ActorRef<Message> extends java.lang.Object implements SendPort<Message>, java.io.Serializable
An actor's external API (for use by code not part of the actor).- See Also:
- Serialized Form
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()This implementation throwsUnsupportedOperationException.voidclose(java.lang.Throwable t)This implementation throwsUnsupportedOperationException.booleanequals(java.lang.Object obj)protected ActorImpl<Message>getImpl()java.lang.StringgetName()inthashCode()protected voidinterrupt()Interrupts the actor's strandvoidsend(Message message)Sends a message to the actor, possibly blocking until there's room available in the mailbox.booleansend(Message message, long timeout, java.util.concurrent.TimeUnit unit)Sends a message to the actor, possibly blocking until there's room available in the mailbox, but never longer than the specified timeout.booleansend(Message message, Timeout timeout)Sends a message to the actor, possibly blocking until there's room available in the mailbox, but never longer than the specified timeout.voidsendSync(Message message)Sends a message to the actor, and attempts to schedule the actor's strand for immediate execution.java.lang.StringtoString()booleantrySend(Message msg)Sends a message to the actor if the channel has mailbox available.-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface co.paralleluniverse.strands.channels.PortAutoCloseable
isClosed
-
-
-
-
Method Detail
-
getName
public java.lang.String getName()
-
send
public void send(Message message) throws SuspendExecution
Sends a message to the actor, possibly blocking until there's room available in the mailbox. If the mailbox is full, this method may block or silently drop the message. The behavior is determined by the mailbox'sOverflowPolicy, set at construction time. However, unlike regular channels, this method never throwsQueueCapacityExceededException. If the mailbox overflows, and has been configured with theTHROWpolicy, the exception will be thrown into the actor.- Specified by:
sendin interfaceSendPort<Message>- Parameters:
message-- Throws:
SuspendExecution
-
sendSync
public void sendSync(Message message) throws SuspendExecution
Sends a message to the actor, and attempts to schedule the actor's strand for immediate execution. This method may be called when a response message is expected from this actor; in this case, this method might provide better latency thansend(java.lang.Object).- Parameters:
message-- Throws:
SuspendExecution
-
send
public boolean send(Message message, long timeout, java.util.concurrent.TimeUnit unit) throws SuspendExecution, java.lang.InterruptedException
Sends a message to the actor, possibly blocking until there's room available in the mailbox, but never longer than the specified timeout. If the mailbox is full, this method may block, throw an exception, silently drop the message, or displace an old message from the channel. The behavior is determined by the mailbox'sOverflowPolicy, set at construction time.Currently, this behavior is not yet supported. The message will be sent using
send(Object)and the timeout argument will be disregarded- Specified by:
sendin interfaceSendPort<Message>- Parameters:
message- the messagetimeout- the maximum duration this method is allowed to wait.unit- the timeout's time unit- Returns:
trueif the message has been sent successfully;falseif the timeout has elapsed.- Throws:
SuspendExecutionjava.lang.InterruptedException
-
send
public boolean send(Message message, Timeout timeout) throws SuspendExecution, java.lang.InterruptedException
Sends a message to the actor, possibly blocking until there's room available in the mailbox, but never longer than the specified timeout. If the channel is full, this method may block, throw an exception, silently drop the message, or displace an old message from the channel. The behavior is determined by the mailbox'sOverflowPolicy, set at construction time.Currently, this behavior is not yet supported. The message will be sent using
send(Object)and the timeout argument will be disregarded- Specified by:
sendin interfaceSendPort<Message>- Parameters:
message- the messagetimeout- the method will not block for longer than the amount remaining in theTimeout- Returns:
trueif the message has been sent successfully;falseif the timeout has elapsed.- Throws:
SuspendExecutionjava.lang.InterruptedException
-
trySend
public boolean trySend(Message msg)
Sends a message to the actor if the channel has mailbox available. This method never blocks.
-
close
public void close()
This implementation throwsUnsupportedOperationException.- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacePortAutoCloseable
-
close
public void close(java.lang.Throwable t)
This implementation throwsUnsupportedOperationException.
-
interrupt
protected void interrupt()
Interrupts the actor's strand
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-