Package akka.testkit

Class CallingThreadDispatcher

  • All Implemented Interfaces:
    BatchingExecutor, java.util.concurrent.Executor, scala.concurrent.ExecutionContext, scala.concurrent.ExecutionContextExecutor

    public class CallingThreadDispatcher
    extends MessageDispatcher
    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.

    Since:
    1.1
    • Method Detail

      • Id

        public static java.lang.String Id()
      • execute

        public static void execute​(java.lang.Runnable runnable)
      • batchable

        public static boolean batchable​(java.lang.Runnable runnable)
      • prepare

        public static scala.concurrent.ExecutionContext prepare()
      • mailboxes

        public static Mailboxes mailboxes()
      • eventStream

        public static EventStream eventStream()
      • inhabitants

        public static final long inhabitants()
      • attach

        public static final void attach​(ActorCell actor)
      • detach

        public static final void detach​(ActorCell actor)
      • resubmitOnBlock

        protected static final boolean resubmitOnBlock()
      • unbatchedExecute

        protected static final void unbatchedExecute​(java.lang.Runnable r)
      • reportFailure

        public static void reportFailure​(java.lang.Throwable t)
      • isThroughputDeadlineTimeDefined

        protected static final boolean isThroughputDeadlineTimeDefined()
      • akka$dispatch$BatchingExecutor$$_tasksLocal

        public static java.lang.ThreadLocal<BatchingExecutor.AbstractBatch> akka$dispatch$BatchingExecutor$$_tasksLocal()
      • akka$dispatch$BatchingExecutor$$_blockContext

        public static java.lang.ThreadLocal<scala.concurrent.BlockContext> akka$dispatch$BatchingExecutor$$_blockContext()
      • akka$dispatch$BatchingExecutor$_setter_$akka$dispatch$BatchingExecutor$$_tasksLocal_$eq

        protected static final void akka$dispatch$BatchingExecutor$_setter_$akka$dispatch$BatchingExecutor$$_tasksLocal_$eq​(java.lang.ThreadLocal<BatchingExecutor.AbstractBatch> x$1)
      • akka$dispatch$BatchingExecutor$_setter_$akka$dispatch$BatchingExecutor$$_blockContext_$eq

        protected static final void akka$dispatch$BatchingExecutor$_setter_$akka$dispatch$BatchingExecutor$$_blockContext_$eq​(java.lang.ThreadLocal<scala.concurrent.BlockContext> x$1)
      • id

        public java.lang.String id()
        Description copied from class: MessageDispatcher
        Identifier of this dispatcher, corresponds to the full key of the dispatcher configuration.
        Specified by:
        id in class MessageDispatcher
        Returns:
        (undocumented)
      • shutdown

        protected void shutdown()
        Description copied from class: MessageDispatcher
        Called one time every time an actor is detached from this dispatcher and this dispatcher has no actors left attached Must be idempotent

        INTERNAL API

        Specified by:
        shutdown in class MessageDispatcher
      • registerForExecution

        protected boolean registerForExecution​(Mailbox mbox,
                                               boolean hasMessageHint,
                                               boolean hasSystemMessageHint)
        Description copied from class: MessageDispatcher
        Suggest to register the provided mailbox for execution

        INTERNAL API

        Specified by:
        registerForExecution in class MessageDispatcher
        Parameters:
        mbox - (undocumented)
        hasMessageHint - (undocumented)
        hasSystemMessageHint - (undocumented)
        Returns:
        (undocumented)
      • shutdownTimeout

        protected scala.concurrent.duration.FiniteDuration shutdownTimeout()
        Description copied from class: MessageDispatcher
        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

        INTERNAL API

        Specified by:
        shutdownTimeout in class MessageDispatcher
        Returns:
        (undocumented)
      • register

        protected void register​(ActorCell actor)
        Description copied from class: MessageDispatcher
        If you override it, you must call it. But only ever once. See "attach" for only invocation.

        INTERNAL API

        Overrides:
        register in class MessageDispatcher
        Parameters:
        actor - (undocumented)
      • unregister

        protected void unregister​(ActorCell actor)
        Description copied from class: MessageDispatcher
        If you override it, you must call it. But only ever once. See "detach" for the only invocation

        INTERNAL API

        Overrides:
        unregister in class MessageDispatcher
        Parameters:
        actor - (undocumented)
      • suspend

        protected void suspend​(ActorCell actor)
        Description copied from class: MessageDispatcher
        After the call to this method, the dispatcher mustn't begin any new message processing for the specified reference
        Overrides:
        suspend in class MessageDispatcher
        Parameters:
        actor - (undocumented)
      • systemDispatch

        protected void systemDispatch​(ActorCell receiver,
                                      SystemMessage message)
        Description copied from class: MessageDispatcher
        Will be called when the dispatcher is to queue an invocation for execution

        INTERNAL API

        Specified by:
        systemDispatch in class MessageDispatcher
        Parameters:
        receiver - (undocumented)
        message - (undocumented)
      • dispatch

        protected void dispatch​(ActorCell receiver,
                                Envelope handle)
        Description copied from class: MessageDispatcher
        Will be called when the dispatcher is to queue an invocation for execution

        INTERNAL API

        Specified by:
        dispatch in class MessageDispatcher
        Parameters:
        receiver - (undocumented)
        handle - (undocumented)