peloton.actor

package peloton.actor

Members list

Type members

Classlikes

abstract class Actor[M]

Actors are the basic building blocks of concurrent computation. In response to a message it receives, an actor can make local decisions, create more actors, send more messages, and determine how to respond to the next message received. Actors may modify their own private state, but can only affect each other indirectly through messaging.

Actors are the basic building blocks of concurrent computation. In response to a message it receives, an actor can make local decisions, create more actors, send more messages, and determine how to respond to the next message received. Actors may modify their own private state, but can only affect each other indirectly through messaging.

Messages sent to an actor are put into a private message inbox. The actor will take each of these messages and process them sequentially by applying them to the actor's message handler function. The result of the message handler function may be given back to the sender of the message (ASK pattern, see below).

There are two different patterns to communicate with an actor:

==The TELL pattern==

When using the TELL pattern, we just send a single message to the actor (which is very fast) and forget about it. No response is expected to be returned by the actor. This pattern is used for asynchronous communication, as it is not guaranteed when the message will be processed by the actor. The message is put at the back of the actor's message queue and processed when all other messages have been processed.

===The ASK pattern==

The ASK pattern is used when a response is required from the actor (synchronous communication). A single message is sent to the actor and the current process (the caller) is suspended until the actor has processed the message and returned a response.

Interacting with an actor is effectful. This is why all actor functions (tell, ask, terminate) are wrapped into an effect type.

Type parameters

M

The actor's base message type (message handler input)

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
object Actor

Attributes

Companion
class
Supertypes
class Object
trait Matchable
class Any
Self type
Actor.type
trait ActorContext[S, M](val currentBehavior: Behavior[S, M])

The actor's context provides some helper functions for its message handler (Behavior)

The actor's context provides some helper functions for its message handler (Behavior)

An instance of the actor context is passed to the actor's message handler, so the handler can use its helper functions.

Type parameters

M

The actor's message base type

S

The type of the actor's internal state

Attributes

Supertypes
class Object
trait Matchable
class Any
trait ActorRef[M]

Attributes

Supertypes
class Object
trait Matchable
class Any
class ActorSystem

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
object ActorSystem

Attributes

Companion
class
Supertypes
class Object
trait Matchable
class Any
Self type
trait Behavior[S, M]

The actor's behavior.

The actor's behavior.

Behavior is basically a function that takes the current state of the Actor and an incoming message as arguments and returns a new Behavor which is then used by the actor to process the next incoming message.

Type parameters

M

The actor's message base type

S

The type of the actor's internal state

Attributes

Supertypes
class Object
trait Matchable
class Any