Actor

final case
class Actor[A](handler: A => Unit, onError: Throwable => Unit)(implicit strategy: Strategy)

Processes messages of type A, one at a time. Messages are submitted to the actor with the method !. Processing is typically performed asynchronously, this is controlled by the provided strategy.

Memory consistency guarantee: when each message is processed by the handler, any memory that it mutates is guaranteed to be visible by the handler when it processes the next message, even if the strategy runs the invocations of handler on separate threads. This is achieved because the Actor reads a volatile memory location before entering its event loop, and writes to the same location before suspending.

Implementation based on non-intrusive MPSC node-based queue, described by Dmitriy Vyukov: http://www.1024cores.net/home/lock-free-algorithms/queues/non-intrusive-mpsc-node-based-queue

Type Params
A

The type of messages accepted by this actor.

Value Params
handler

The message handler

onError

Exception handler, called if the message handler throws any Throwable.

strategy

Execution strategy, for example, a strategy that is backed by an ExecutorService

Companion
object
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any

Value members

Concrete methods

def !(a: A): Unit

Alias for apply

Alias for apply

def apply(a: A): Unit

Pass the message a to the mailbox of this actor

Pass the message a to the mailbox of this actor

def contramap[B](f: B => A): Actor[B]

Inherited methods

def productElementNames: Iterator[String]
Inherited from
Product
def productIterator: Iterator[Any]
Inherited from
Product

Concrete fields

val toEffect: Run[A]

Implicits

Implicits

implicit