Package akka.dispatch
Class Mailbox
- java.lang.Object
-
- akka.dispatch.forkjoin.ForkJoinTask<scala.runtime.BoxedUnit>
-
- akka.dispatch.Mailbox
-
- All Implemented Interfaces:
SystemMessageQueue,java.io.Serializable,java.lang.Runnable,java.util.concurrent.Future<scala.runtime.BoxedUnit>
- Direct Known Subclasses:
CallingThreadMailbox
public abstract class Mailbox extends ForkJoinTask<scala.runtime.BoxedUnit> implements SystemMessageQueue, java.lang.Runnable
Try to enqueue the message to this queue, or throw an exception.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description Mailbox(MessageQueue messageQueue)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected int_statusDoNotCallMeDirectly()protected void_statusDoNotCallMeDirectly_$eq(int x$1)protected SystemMessage_systemQueueDoNotCallMeDirectly()protected void_systemQueueDoNotCallMeDirectly_$eq(SystemMessage x$1)ActorCellactor()voidactor_$eq(ActorCell x$1)booleanbecomeClosed()set new primary status Closed.booleancanBeScheduledForExecution(boolean hasMessageHint, boolean hasSystemMessageHint)protected voidcleanUp()Overridable callback to clean up the mailbox, called when an actor is unregistered.static intClosed()intcurrentStatus()static booleandebug()Envelopedequeue()Try to dequeue the next message from this queue, return null failing that.MessageDispatcherdispatcher()voidenqueue(ActorRef receiver, Envelope msg)Try to enqueue the message to this queue, or throw an exception.booleanexec()Immediately performs the base action of this task and returns true if, upon return from this method, this task is guaranteed to have completed normally.voidgetRawResult()booleanhasMessages()Indicates whether this queue is non-empty.booleanisClosed()booleanisScheduled()booleanisSuspended()MessageQueuemessageQueue()intnumberOfMessages()Should return the current number of messages held in this queue; may always return 0 if no other value is available efficiently.static intOpen()voidprocessAllSystemMessages()Will at least try to process all queued system messages: in case of failure simply drop and go on to the next, because there is nothing to restart here (failure is in ActorCell somewhere …).booleanresume()Reduce the suspend count by one.voidrun()static intScheduled()voidsetActor(ActorCell cell)booleansetAsIdle()Reset Scheduled status, keeping primary status as is.booleansetAsScheduled()Set Scheduled status, keeping primary status as is.voidsetRawResult(scala.runtime.BoxedUnit unit)Forces the given value to be returned as a result.protected voidsetStatus(int newStatus)static intshouldNotProcessMask()booleanshouldProcessMessage()static intshouldScheduleMask()booleansuspend()Increment the suspend count by one.intsuspendCount()static intsuspendMask()static intsuspendUnit()protected LatestFirstSystemMessageListsystemQueueGet()protected booleansystemQueuePut(LatestFirstSystemMessageList _old, LatestFirstSystemMessageList _new)protected booleanupdateStatus(int oldStatus, int newStatus)-
Methods inherited from class akka.dispatch.forkjoin.ForkJoinTask
adapt, adapt, adapt, cancel, compareAndSetForkJoinTaskTag, complete, completeExceptionally, fork, get, get, getException, getForkJoinTaskTag, getPool, getQueuedTaskCount, getSurplusQueuedTaskCount, helpQuiesce, inForkJoinPool, invoke, invokeAll, invokeAll, invokeAll, isCancelled, isCompletedAbnormally, isCompletedNormally, isDone, join, peekNextLocalTask, pollNextLocalTask, pollTask, quietlyComplete, quietlyInvoke, quietlyJoin, reinitialize, setForkJoinTaskTag, tryUnfork
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface akka.dispatch.SystemMessageQueue
hasSystemMessages, systemDrain, systemEnqueue
-
-
-
-
Constructor Detail
-
Mailbox
public Mailbox(MessageQueue messageQueue)
-
-
Method Detail
-
Open
public static final int Open()
-
Closed
public static final int Closed()
-
Scheduled
public static final int Scheduled()
-
shouldScheduleMask
public static final int shouldScheduleMask()
-
shouldNotProcessMask
public static final int shouldNotProcessMask()
-
suspendMask
public static final int suspendMask()
-
suspendUnit
public static final int suspendUnit()
-
debug
public static final boolean debug()
-
messageQueue
public MessageQueue messageQueue()
-
actor
public ActorCell actor()
-
actor_$eq
public void actor_$eq(ActorCell x$1)
-
setActor
public void setActor(ActorCell cell)
-
dispatcher
public MessageDispatcher dispatcher()
-
enqueue
public void enqueue(ActorRef receiver, Envelope msg)
Try to enqueue the message to this queue, or throw an exception.- Parameters:
receiver- (undocumented)msg- (undocumented)
-
dequeue
public Envelope dequeue()
Try to dequeue the next message from this queue, return null failing that.- Returns:
- (undocumented)
-
hasMessages
public boolean hasMessages()
Indicates whether this queue is non-empty.- Returns:
- (undocumented)
-
numberOfMessages
public int numberOfMessages()
Should return the current number of messages held in this queue; may always return 0 if no other value is available efficiently. Do not use this for testing for presence of messages, usehasMessagesinstead.- Returns:
- (undocumented)
-
_statusDoNotCallMeDirectly
protected int _statusDoNotCallMeDirectly()
-
_statusDoNotCallMeDirectly_$eq
protected void _statusDoNotCallMeDirectly_$eq(int x$1)
-
_systemQueueDoNotCallMeDirectly
protected SystemMessage _systemQueueDoNotCallMeDirectly()
-
_systemQueueDoNotCallMeDirectly_$eq
protected void _systemQueueDoNotCallMeDirectly_$eq(SystemMessage x$1)
-
currentStatus
public final int currentStatus()
-
shouldProcessMessage
public final boolean shouldProcessMessage()
-
suspendCount
public final int suspendCount()
-
isSuspended
public final boolean isSuspended()
-
isClosed
public final boolean isClosed()
-
isScheduled
public final boolean isScheduled()
-
updateStatus
protected final boolean updateStatus(int oldStatus, int newStatus)
-
setStatus
protected final void setStatus(int newStatus)
-
resume
public final boolean resume()
Reduce the suspend count by one. Caller does not need to worry about whether status was Scheduled or not.- Returns:
- true if the suspend count reached zero
-
suspend
public final boolean suspend()
Increment the suspend count by one. Caller does not need to worry about whether status was Scheduled or not.- Returns:
- true if the previous suspend count was zero
-
becomeClosed
public final boolean becomeClosed()
set new primary status Closed. Caller does not need to worry about whether status was Scheduled or not.- Returns:
- (undocumented)
-
setAsScheduled
public final boolean setAsScheduled()
Set Scheduled status, keeping primary status as is.- Returns:
- (undocumented)
-
setAsIdle
public final boolean setAsIdle()
Reset Scheduled status, keeping primary status as is.- Returns:
- (undocumented)
-
systemQueueGet
protected final LatestFirstSystemMessageList systemQueueGet()
-
systemQueuePut
protected final boolean systemQueuePut(LatestFirstSystemMessageList _old, LatestFirstSystemMessageList _new)
-
canBeScheduledForExecution
public final boolean canBeScheduledForExecution(boolean hasMessageHint, boolean hasSystemMessageHint)
-
run
public final void run()
- Specified by:
runin interfacejava.lang.Runnable
-
getRawResult
public final void getRawResult()
-
setRawResult
public final void setRawResult(scala.runtime.BoxedUnit unit)
Description copied from class:ForkJoinTaskForces the given value to be returned as a result. This method is designed to support extensions, and should not in general be called otherwise.- Specified by:
setRawResultin classForkJoinTask<scala.runtime.BoxedUnit>- Parameters:
unit- the value
-
exec
public final boolean exec()
Description copied from class:ForkJoinTaskImmediately performs the base action of this task and returns true if, upon return from this method, this task is guaranteed to have completed normally. This method may return false otherwise, to indicate that this task is not necessarily complete (or is not known to be complete), for example in asynchronous actions that require explicit invocations of completion methods. This method may also throw an (unchecked) exception to indicate abnormal exit. This method is designed to support extensions, and should not in general be called otherwise.- Specified by:
execin classForkJoinTask<scala.runtime.BoxedUnit>- Returns:
trueif this task is known to have completed normally
-
processAllSystemMessages
public final void processAllSystemMessages()
Will at least try to process all queued system messages: in case of failure simply drop and go on to the next, because there is nothing to restart here (failure is in ActorCell somewhere …). In case the mailbox becomes closed (because of processing a Terminate message), dump all already dequeued message to deadLetters.
-
cleanUp
protected void cleanUp()
Overridable callback to clean up the mailbox, called when an actor is unregistered. By default it dequeues all system messages + messages and ships them to the owning actors' systems' DeadLetterMailbox
-
-