ActorContext

s2a.leucine.actors.ActorContext
See theActorContext companion object
trait ActorContext extends PlatformContext, ExecutionContext

An extended scala.concurrent.ExecutionContext; provides the ability to schedule messages to be sent later, and hooks to track the current number of outstanding tasks or log the actor message sends for debugging purposes

Attributes

Companion
object
Graph
Supertypes
trait ExecutionContext
class Object
trait Matchable
class Any
Known subtypes

Members list

Value members

Abstract methods

The character that will be used in the full name definitions of the actors.

The character that will be used in the full name definitions of the actors.

Attributes

def maxMailboxSize: Int

Global maximum number of letters per mailbox.

Global maximum number of letters per mailbox.

Attributes

def silentStop: Int

The minimal number of poll loops (from the guard) for an actor to be considered silent.

The minimal number of poll loops (from the guard) for an actor to be considered silent.

Attributes

def traceln(s: => String): Unit

Helper method for tracing while debugging. Wrap your debug lines in traceln()

Helper method for tracing while debugging. Wrap your debug lines in traceln()

Attributes

def workerPrefix: String

The prefix used in actor names for actors that are workers

The prefix used in actor names for actors that are workers

Attributes

Concrete methods

def delayed(task: => Unit, time: FiniteDuration): Cancellable

Delayed task to be executed on the ActorContext.

Delayed task to be executed on the ActorContext.

Attributes

def future[T](task: => T): Future[T]

Future to be executed on the ActorContext.

Future to be executed on the ActorContext.

Attributes

def reportFailure(cause: Throwable): Unit

Default way to handle an exception. Override if needed.

Default way to handle an exception. Override if needed.

Attributes

Inherited methods

def active: Boolean

True as long as there has been no Shutdown request.

True as long as there has been no Shutdown request.

Attributes

Inherited from:
PlatformContext
def await[M](digestible: Digestible[M], attempt: => Option[M]): Cancellable

Place a task on the Execution Context which is executed after some event arrives. When it arrives it may produce an result of some type. This result is subsequently passed to the digestible process. As longs as there is no result yet, the attempt should produce None

Place a task on the Execution Context which is executed after some event arrives. When it arrives it may produce an result of some type. This result is subsequently passed to the digestible process. As longs as there is no result yet, the attempt should produce None

Attributes

Inherited from:
PlatformContext
def emulated: Boolean

Indicates if the context runs on system threads or in an emulated environment.

Indicates if the context runs on system threads or in an emulated environment.

Attributes

Inherited from:
PlatformContext
def execute(runnable: Runnable): Unit

Attributes

Inherited from:
ExecutionContext
def idleThreadPause: FiniteDuration

The natural pause time for this context. Its meaning and use is platform dependent.

The natural pause time for this context. Its meaning and use is platform dependent.

Attributes

Inherited from:
PlatformContext

Method to detect on which platform the code is running.

Method to detect on which platform the code is running.

Attributes

Inherited from:
PlatformContext
def schedule(callable: Callable[Unit], delay: FiniteDuration): Cancellable

Plan a new task on the current Execution Context, which is run after some delay. Depending on the platform, the execution of multiple delayed tasks can hinder each other. So it is best to keep the execution time within the callable low, and transfer work to the thread pool.

Plan a new task on the current Execution Context, which is run after some delay. Depending on the platform, the execution of multiple delayed tasks can hinder each other. So it is best to keep the execution time within the callable low, and transfer work to the thread pool.

Attributes

Inherited from:
PlatformContext
def shutdown(force: Boolean): Unit

Perform a shutdown request. With force=false, the shutdown will be effective if all threads have completed there current tasks. With force=true the current execution is interrupted. In any case, no new tasks will be accepted.

Perform a shutdown request. With force=false, the shutdown will be effective if all threads have completed there current tasks. With force=true the current execution is interrupted. In any case, no new tasks will be accepted.

Attributes

Inherited from:
PlatformContext
def terminated: Boolean

True if all treads have completed, for JS this is never the case since the main thread is always running. We cannot probe if the tasks there were scheduled manually all have been completed.

True if all treads have completed, for JS this is never the case since the main thread is always running. We cannot probe if the tasks there were scheduled manually all have been completed.

Attributes

Inherited from:
PlatformContext
def threadsPerCore: Int

The average thread load per core. Override to change. This is only used on multithreaded platforms.

The average thread load per core. Override to change. This is only used on multithreaded platforms.

Attributes

Inherited from:
PlatformContext
def waitForExit(force: Boolean, time: FiniteDuration)(shutdownRequest: => Boolean, complete: () => Unit): Unit

This method waits until the application finishes. Every timeout, it will probe a shutdown request. There may be other reasons for shutdown as well. After all threads have completed (by force or not) the method calls complete(). Call waitForExit in the main thread as last action there. After return some other tasks may still be running. This will usually not be a problem, since when they complete the application will exit, just as intended, or, inside a web app, keeps running, needed to be able to continue to respond on other events. The method may also directly return, if blocking is not supported by the platform (JS). In that case the callback complete provides the correct information.

This method waits until the application finishes. Every timeout, it will probe a shutdown request. There may be other reasons for shutdown as well. After all threads have completed (by force or not) the method calls complete(). Call waitForExit in the main thread as last action there. After return some other tasks may still be running. This will usually not be a problem, since when they complete the application will exit, just as intended, or, inside a web app, keeps running, needed to be able to continue to respond on other events. The method may also directly return, if blocking is not supported by the platform (JS). In that case the callback complete provides the correct information.

Attributes

Inherited from:
PlatformContext

Deprecated and Inherited methods

def prepare(): ExecutionContext

Attributes

Deprecated
[Since version 2.12.0] preparation of ExecutionContexts will be removed
Inherited from:
ExecutionContext