scala.actors

object Actor

[source: scala/actors/Actor.scala]

object Actor
extends AnyRef
The Actor object provides functions for the definition of actors, as well as actor operations, such as receive, react, reply, etc.
Version
0.9.14
Author
Philipp Haller
Method Summary
def ? : Any
Receives the next message from the mailbox of the current actor self.
def actor (body : => Unit) : Actor
def clearSelf : Unit
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.
def continue : Unit
def eventloop (f : PartialFunction[Any, Unit]) : Nothing
def exit (reason : AnyRef) : Nothing
def exit : Nothing
def link (to : Actor) : Actor
Links self to actor to.
def link (body : => Unit) : Actor
Links self to actor defined by body.
def loop (body : => Unit) : Unit
Causes self to repeatedly execute body.
def loopWhile (cond : => Boolean)(body : => Unit) : Unit
Causes self to repeatedly execute body while the condition cond is true.
def mailboxSize : Int
Returns the number of messages in self's mailbox
implicit def mkBody [a](body : => a) : Body[a]
def react (f : PartialFunction[Any, Unit]) : Nothing
Lightweight variant of receive. Actions in f have to contain the rest of the computation of self, as this method will never return.
def reactWithin (msec : Long)(f : PartialFunction[Any, Unit]) : Nothing
Lightweight variant of receiveWithin. Actions in f have to contain the rest of the computation of self, as this method will never return.
def receive [A](f : PartialFunction[Any, A]) : A
Receives a message from the mailbox of self. Blocks if no message matching any of the cases of f can be received.
def receiveWithin [R](msec : Long)(f : PartialFunction[Any, R]) : R
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.
def reply (msg : Any) : Unit
Send msg to the actor waiting in a call to !?.
def reply : Unit
Send () to the actor waiting in a call to !?.
def resetProxy : Unit
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.
def self : Actor
Returns the currently executing actor. Should be used instead of this in all blocks of code executed by actors.
def sender : OutputChannel[Any]
Returns the actor which sent the last received message.
def unlink (from : Actor) : Unit
Unlinks self from actor from.
Methods inherited from AnyRef
getClass, hashCode, equals, clone, toString, notify, notifyAll, wait, wait, wait, finalize, ==, !=, eq, ne, synchronized
Methods inherited from Any
==, !=, isInstanceOf, asInstanceOf
Method Details
def self : Actor
Returns the currently executing actor. Should be used instead of this in all blocks of code executed by actors.
Returns
returns the currently executing actor.

def resetProxy : Unit
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.

def clearSelf : Unit
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.

def actor(body : => Unit) : Actor

This function is used for the definition of actors.

The following example demonstrates its usage:

   import scala.actors.Actor._
   ...
   val a = actor {
     ...
   }
   
Parameters
body - the code block to be executed by the newly created actor
Returns
the newly created actor. Note that it is automatically started.

def ? : Any
Receives the next message from the mailbox of the current actor self.

def receive[A](f : PartialFunction[Any, A]) : A
Receives a message from the mailbox of self. Blocks if no message matching any of the cases of f can be received.
Parameters
f - a partial function specifying patterns and actions
Returns
the result of processing the received message

def receiveWithin[R](msec : Long)(f : PartialFunction[Any, R]) : R
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.
Parameters
msec - the time span before timeout
f - a partial function specifying patterns and actions
Returns
the result of processing the received message

def react(f : PartialFunction[Any, Unit]) : Nothing
Lightweight variant of receive. Actions in f have to contain the rest of the computation of self, as this method will never return.
Parameters
f - a partial function specifying patterns and actions
Returns
this function never returns

def reactWithin(msec : Long)(f : PartialFunction[Any, Unit]) : Nothing
Lightweight variant of receiveWithin. Actions in f have to contain the rest of the computation of self, as this method will never return.
Parameters
msec - the time span before timeout
f - a partial function specifying patterns and actions
Returns
this function never returns

def eventloop(f : PartialFunction[Any, Unit]) : Nothing

def sender : OutputChannel[Any]
Returns the actor which sent the last received message.

def reply(msg : Any) : Unit
Send msg to the actor waiting in a call to !?.

def reply : Unit
Send () to the actor waiting in a call to !?.

def mailboxSize : Int
Returns the number of messages in self's mailbox
Returns
the number of messages in self's mailbox

implicit def mkBody[a](body : => a) : Body[a]

def loop(body : => Unit) : Unit
Causes self to repeatedly execute body.
Parameters
body - the code block to be executed

def loopWhile(cond : => Boolean)(body : => Unit) : Unit
Causes self to repeatedly execute body while the condition cond is true.
Parameters
cond - the condition to test
body - the code block to be executed

def link(to : Actor) : Actor
Links self to actor to.
Parameters
to - the actor to link to
Returns

def link(body : => Unit) : Actor
Links self to actor defined by body.
Parameters
body - ...
Returns
...

def unlink(from : Actor) : Unit
Unlinks self from actor from.
Parameters
from - the actor to unlink from

def exit(reason : AnyRef) : Nothing

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.


def exit : Nothing

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.


def continue : Unit