scala.actors

Actor

object Actor extends Combinators with Serializable

Provides functions for the definition of actors, as well as actor operations, such as receive, react, reply, etc.

Annotations
@deprecated
Deprecated

(Since version 2.11.0) Use the akka.actor package instead. For migration from the scala.actors package refer to the Actors Migration Guide.

Linear Supertypes
Serializable, java.io.Serializable, Combinators, AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. Actor
  2. Serializable
  3. Serializable
  4. Combinators
  5. AnyRef
  6. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Value Members

  1. final def !=(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  4. def ?: Any

    Receives the next message from the mailbox of the current actor self.

  5. object State extends Enumeration

    State of an actor.

  6. def actor(body: ⇒ Unit): Actor

    Factory method for creating and starting an actor.

    Factory method for creating and starting an actor.

    body

    the code block to be executed by the newly created actor

    returns

    the newly created actor. Note that it is automatically started.

    Example:
    1. import scala.actors.Actor._
      ...
      val a = actor {
        ...
      }
  7. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  8. def clearSelf(): Unit

    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.

  9. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  10. def continue(): Unit

    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.

    Definition Classes
    Combinators
  11. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  12. def equals(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  13. def eventloop(f: PartialFunction[Any, Unit]): Nothing

  14. def exit(): Nothing

    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.

  15. def exit(reason: AnyRef): Nothing

    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.

  16. def finalize(): Unit

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  17. final def getClass(): Class[_]

    Definition Classes
    AnyRef → Any
  18. def hashCode(): Int

    Definition Classes
    AnyRef → Any
  19. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  20. def link(body: ⇒ Unit): Actor

    Links self to the actor defined by body.

    Links self to the actor defined by body.

    body

    the body of the actor to link to

    returns

    the parameter actor

  21. def link(to: AbstractActor): AbstractActor

    Links self to actor to.

    Links self to actor to.

    to

    the actor to link to

    returns

    the parameter actor

  22. def loop(body: ⇒ Unit): Unit

    Repeatedly executes body.

    Repeatedly executes body.

    body

    the block to be executed

    Definition Classes
    Combinators
  23. def loopWhile(cond: ⇒ Boolean)(body: ⇒ Unit): Unit

    Repeatedly executes body while the condition cond is true.

    Repeatedly executes body while the condition cond is true.

    cond

    the condition to test

    body

    the block to be executed

    Definition Classes
    Combinators
  24. def mailboxSize: Int

    Returns the number of messages in self's mailbox

    Returns the number of messages in self's mailbox

    returns

    the number of messages in self's mailbox

  25. implicit def mkBody[a](body: ⇒ a): InternalActor.Body[a]

    Enables the composition of suspendable closures using andThen, loop, loopWhile, etc.

    Enables the composition of suspendable closures using andThen, loop, loopWhile, etc.

    Definition Classes
    Actor → Combinators
  26. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  27. final def notify(): Unit

    Definition Classes
    AnyRef
  28. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  29. def react(f: PartialFunction[Any, Unit]): Nothing

    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
    }
    }
    f

    a partial function specifying patterns and actions

    returns

    this function never returns

  30. def reactWithin(msec: Long)(f: PartialFunction[Any, Unit]): Nothing

    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.

    msec

    the time span before timeout

    f

    a partial function specifying patterns and actions

    returns

    this function never returns

  31. def reactor(body: ⇒ Responder[Unit]): Actor

    Factory method for creating actors whose body is defined using a Responder.

    Factory method for creating actors whose body is defined using a Responder.

    body

    the Responder to be executed by the newly created actor

    returns

    the newly created actor. Note that it is automatically started.

    Example:
    1. import scala.actors.Actor._
      import Responder.exec
      ...
      val a = reactor {
        for {
          res <- b !! MyRequest;
          if exec(println("result: "+res))
        } yield {}
      }
  32. def receive[A](f: PartialFunction[Any, A]): A

    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.

    f

    a partial function specifying patterns and actions

    returns

    the result of processing the received message

    Example:
    1. receive {
      case "exit" => println("exiting")
      case 42 => println("got the answer")
      case x:Int => println("got an answer")
      }
  33. def receiveWithin[R](msec: Long)(f: PartialFunction[Any, R]): R

    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.

    msec

    the time span before timeout

    f

    a partial function specifying patterns and actions

    returns

    the result of processing the received message

  34. def reply(): Unit

    Sends () to the actor waiting in a call to !?.

  35. def reply(msg: Any): Unit

    Sends msg to the actor waiting in a call to !?.

  36. def resetProxy(): Unit

    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.

  37. def respondOn[A, B](fun: (PartialFunction[A, Unit]) ⇒ Nothing): (PartialFunction[A, B]) ⇒ Responder[B]

    Converts a synchronous event-based operation into an asynchronous Responder.

    Converts a synchronous event-based operation into an asynchronous Responder.

    Example:
    1. val adder = reactor {
      for {
        _ <- respondOn(react) { case Add(a, b) => reply(a+b) }
      } yield {}
      }
  38. def self: Actor

    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

    returns the currently executing actor.

  39. def sender: OutputChannel[Any]

    Returns the actor which sent the last received message.

  40. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  41. def toString(): String

    Definition Classes
    AnyRef → Any
  42. def unlink(from: AbstractActor): Unit

    Unlinks self from actor from.

    Unlinks self from actor from.

    from

    the actor to unlink from

  43. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  44. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  45. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from Serializable

Inherited from java.io.Serializable

Inherited from Combinators

Inherited from AnyRef

Inherited from Any

Ungrouped