Receives the next message from the mailbox of the current actor self
.
State of an actor.
Factory method for creating and starting an actor.
Factory method for creating and starting an actor.
the code block to be executed by the newly created actor
the newly created actor. Note that it is automatically started.
import scala.actors.Actor._ ... val a = actor { ... }
Removes any reference to an Actor
instance
currently stored in thread-local storage.
Removes any reference to an Actor
instance
currently stored in thread-local storage.
This allows to release references from threads that are potentially long-running or being re-used (e.g. inside a thread pool). Permanent references in thread-local storage are a potential memory leak.
Continues with the execution of the closure registered as
continuation following andThen
.
Continues with the execution of the closure registered as
continuation following andThen
. Continues with the execution
of the next loop iteration when invoked inside the body of loop
or loopWhile
.
Terminates execution of self
with the following effect on
linked actors:
Terminates execution of self
with the following effect on
linked actors:
For each linked actor a
with trapExit
set to true
,
send message Exit(self, 'normal)
to a
.
Terminates execution of self
with the following effect on
linked actors:
Terminates execution of self
with the following effect on
linked actors:
For each linked actor a
with trapExit
set to true
,
send message Exit(self, reason)
to a
.
For each linked actor a
with trapExit
set to false
(default), call a.exit(reason)
if reason != 'normal
.
Links self
to the actor defined by body
.
Links self
to the actor defined by body
.
the body of the actor to link to
the parameter actor
Links self
to actor to
.
Links self
to actor to
.
the actor to link to
the parameter actor
Repeatedly executes body
.
Repeatedly executes body
.
the block to be executed
Repeatedly executes body
while the condition cond
is true
.
Repeatedly executes body
while the condition cond
is true
.
the condition to test
the block to be executed
Returns the number of messages in self
's mailbox
Returns the number of messages in self
's mailbox
the number of messages in self
's mailbox
Enables the composition of suspendable closures using andThen
,
loop
, loopWhile
, etc.
Enables the composition of suspendable closures using andThen
,
loop
, loopWhile
, etc.
Lightweight variant of receive
.
Lightweight variant of receive
.
Actions in f
have to contain the rest of the computation of self
,
as this method will never return.
A common method of continuting the computation is to send a message to another actor:
react { case Get(from) => react { case Put(x) => from ! x } }
Another common method is to use loop
to continuously react
to messages:
loop { react { case Msg(data) => // process data } }
a partial function specifying patterns and actions
this function never returns
Lightweight variant of receiveWithin
.
Lightweight variant of receiveWithin
.
Actions in f
have to contain the rest of the computation of self
,
as this method will never return.
the time span before timeout
a partial function specifying patterns and actions
this function never returns
Factory method for creating actors whose
body is defined using a Responder
.
Factory method for creating actors whose
body is defined using a Responder
.
the Responder
to be executed by the newly created actor
the newly created actor. Note that it is automatically started.
import scala.actors.Actor._ import Responder.exec ... val a = reactor { for { res <- b !! MyRequest; if exec(println("result: "+res)) } yield {} }
Receives a message from the mailbox of self
.
Receives a message from the mailbox of self
. Blocks if no message
matching any of the cases of f
can be received.
a partial function specifying patterns and actions
the result of processing the received message
receive { case "exit" => println("exiting") case 42 => println("got the answer") case x:Int => println("got an answer") }
Receives a message from the mailbox of self
.
Receives a message from the mailbox of self
. Blocks at most msec
milliseconds if no message matching any of the cases of f
can be
received. If no message could be received the TIMEOUT
action is
executed if specified.
the time span before timeout
a partial function specifying patterns and actions
the result of processing the received message
Sends ()
to the actor waiting in a call to !?
.
Sends msg
to the actor waiting in a call to !?
.
Resets an actor proxy associated with the current thread.
Resets an actor proxy associated with the current thread.
It replaces the implicit ActorProxy
instance
of the current thread (if any) with a new instance.
This permits to re-use the current thread as an actor
even if its ActorProxy
has died for some reason.
Converts a synchronous event-based operation into
an asynchronous Responder
.
Converts a synchronous event-based operation into
an asynchronous Responder
.
val adder = reactor { for { _ <- respondOn(react) { case Add(a, b) => reply(a+b) } } yield {} }
Returns the currently executing actor.
Returns the currently executing actor. Should be used instead
of this
in all blocks of code executed by actors.
returns the currently executing actor.
Returns the actor which sent the last received message.
Unlinks self
from actor from
.
Unlinks self
from actor from
.
the actor to unlink from
Provides functions for the definition of actors, as well as actor operations, such as
receive
,react
,reply
, etc.(Since version 2.11.0) Use the akka.actor package instead. For migration from the scala.actors package refer to the Actors Migration Guide.