|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object akka.dispatch.MessageDispatcher akka.testkit.CallingThreadDispatcher
public class CallingThreadDispatcher
Dispatcher which runs invocations on the current thread only. This dispatcher does not create any new threads, but it can be used from different threads concurrently for the same actor. The dispatch strategy is to run on the current thread unless the target actor is either suspendSwitch or already running on the current thread (if it is running on a different thread, then this thread will block until that other invocation is finished); if the invocation is not run, it is queued in a thread-local queue to be executed once the active invocation further up the call stack finishes. This leads to completely deterministic execution order if only one thread is used.
Suspending and resuming are global actions for one actor, meaning they can affect different threads, which leads to complications. If messages are queued (thread-locally) during the suspendSwitch period, the only thread to run them upon resume is the thread actually calling the resume method. Hence, all thread-local queues which are not currently being drained (possible, since suspend-queue-resume might happen entirely during an invocation on a different thread) are scooped up into the current thread-local queue which is then executed. It is possible to suspend an actor from within its call stack.
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface scala.concurrent.ExecutionContext |
---|
scala.concurrent.ExecutionContext.Implicits$ |
Constructor Summary | |
---|---|
CallingThreadDispatcher(MessageDispatcherConfigurator _configurator)
|
Method Summary | |
---|---|
protected CallingThreadMailbox |
createMailbox(Cell actor,
MailboxType mailboxType)
Creates and returns a mailbox for the given actor. |
protected void |
dispatch(ActorCell receiver,
Envelope handle)
Will be called when the dispatcher is to queue an invocation for execution |
protected void |
executeTask(TaskInvocation invocation)
INTERNAL API |
java.lang.String |
id()
Identifier of this dispatcher, corresponds to the full key of the dispatcher configuration. |
static java.lang.String |
Id()
|
LoggingAdapter |
log()
|
protected void |
register(ActorCell actor)
If you override it, you must call it. |
protected boolean |
registerForExecution(Mailbox mbox,
boolean hasMessageHint,
boolean hasSystemMessageHint)
Suggest to register the provided mailbox for execution |
protected void |
resume(ActorCell actor)
|
protected void |
shutdown()
Called one time every time an actor is detached from this dispatcher and this dispatcher has no actors left attached Must be idempotent |
protected scala.concurrent.duration.FiniteDuration |
shutdownTimeout()
When the dispatcher no longer has any actors registered, how long will it wait until it shuts itself down, defaulting to your akka configs "akka.actor.default-dispatcher.shutdown-timeout" or default specified in reference.conf |
protected void |
suspend(ActorCell actor)
After the call to this method, the dispatcher mustn't begin any new message processing for the specified reference |
protected void |
systemDispatch(ActorCell receiver,
SystemMessage message)
Will be called when the dispatcher is to queue an invocation for execution |
protected int |
throughput()
INTERNAL API |
protected scala.concurrent.duration.FiniteDuration |
throughputDeadlineTime()
INTERNAL API |
protected void |
unregister(ActorCell actor)
If you override it, you must call it. |
Methods inherited from class akka.dispatch.MessageDispatcher |
---|
actors, attach, configurator, debug, detach, eventStream, inhabitants, isThroughputDeadlineTimeDefined, mailboxes, printActors, reportFailure, RESCHEDULED, resubmitOnBlock, SCHEDULED, unbatchedExecute, UNSCHEDULED |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface akka.dispatch.BatchingExecutor |
---|
batchable, execute |
Methods inherited from interface scala.concurrent.ExecutionContext |
---|
execute, prepare |
Constructor Detail |
---|
public CallingThreadDispatcher(MessageDispatcherConfigurator _configurator)
Method Detail |
---|
public static java.lang.String Id()
public LoggingAdapter log()
public java.lang.String id()
MessageDispatcher
id
in class MessageDispatcher
protected CallingThreadMailbox createMailbox(Cell actor, MailboxType mailboxType)
MessageDispatcher
createMailbox
in class MessageDispatcher
actor
- (undocumented)mailboxType
- (undocumented)
protected void shutdown()
MessageDispatcher
INTERNAL API
shutdown
in class MessageDispatcher
protected int throughput()
MessageDispatcher
throughput
in class MessageDispatcher
protected scala.concurrent.duration.FiniteDuration throughputDeadlineTime()
MessageDispatcher
throughputDeadlineTime
in class MessageDispatcher
protected boolean registerForExecution(Mailbox mbox, boolean hasMessageHint, boolean hasSystemMessageHint)
MessageDispatcher
INTERNAL API
registerForExecution
in class MessageDispatcher
mbox
- (undocumented)hasMessageHint
- (undocumented)hasSystemMessageHint
- (undocumented)
protected scala.concurrent.duration.FiniteDuration shutdownTimeout()
MessageDispatcher
INTERNAL API
shutdownTimeout
in class MessageDispatcher
protected void register(ActorCell actor)
MessageDispatcher
INTERNAL API
register
in class MessageDispatcher
actor
- (undocumented)protected void unregister(ActorCell actor)
MessageDispatcher
INTERNAL API
unregister
in class MessageDispatcher
actor
- (undocumented)protected void suspend(ActorCell actor)
MessageDispatcher
suspend
in class MessageDispatcher
actor
- (undocumented)protected void resume(ActorCell actor)
resume
in class MessageDispatcher
protected void systemDispatch(ActorCell receiver, SystemMessage message)
MessageDispatcher
INTERNAL API
systemDispatch
in class MessageDispatcher
receiver
- (undocumented)message
- (undocumented)protected void dispatch(ActorCell receiver, Envelope handle)
MessageDispatcher
INTERNAL API
dispatch
in class MessageDispatcher
receiver
- (undocumented)handle
- (undocumented)protected void executeTask(TaskInvocation invocation)
MessageDispatcher
executeTask
in class MessageDispatcher
invocation
- (undocumented)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |