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 all actor operations, such as `receive`, `react`, `reply`, etc.

Version
  0.9.7
Author
  Philipp Haller

Value Summary
`val` | tl : ThreadLocal

Method Summary
`def` | ? : Any Receives the next message from the mailbox of the current actor `self`.
`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 {
         ...
       }
`def` | continue : Unit
`def` | eventloop (f : PartialFunction[Any, Unit]) : Nothing
`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` | 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` | 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) : Nothing Causes `self` to repeatedly execute `body`.
`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 : Unit Send `()` to the actor waiting in a call to `!?`.
`def` | reply (msg : Any) : Unit Send `msg` 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 : Actor 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

Class Summary
`trait` | Body [a]`extends` AnyRef

Value Details

`` `val` tl : ThreadLocal

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` 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 : Actor

  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 `!?`.

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

`` `def` loop(body : => Unit) : Nothing

  Causes `self` to repeatedly execute `body`.

Parameters
  `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