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.

Source
Actor.scala
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: AnyRef): Boolean

    Definition Classes
    AnyRef
  2. final def !=(arg0: Any): Boolean

    Test two objects for inequality.

    Test two objects for inequality.

    returns

    true if !(this == that), false otherwise.

    Definition Classes
    Any
  3. final def ##(): Int

    Equivalent to x.hashCode except for boxed numeric types and null.

    Equivalent to x.hashCode except for boxed numeric types and null. For numerics, it returns a hash value which is consistent with value equality: if two value type instances compare as true, then ## will produce the same hash value for each of them. For null returns a hashcode where null.hashCode throws a NullPointerException.

    returns

    a hash value consistent with ==

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

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

    Test two objects for equality.

    Test two objects for equality. The expression x == that is equivalent to if (x eq null) that eq null else x.equals(that).

    returns

    true if the receiver object is equivalent to the argument; false otherwise.

    Definition Classes
    Any
  6. def ?: Any

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

  7. object State extends Enumeration

    State of an actor.

  8. 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 {
        ...
      }
  9. final def asInstanceOf[T0]: T0

    Cast the receiver object to be of type T0.

    Cast the receiver object to be of type T0.

    Note that the success of a cast at runtime is modulo Scala's erasure semantics. Therefore the expression 1.asInstanceOf[String] will throw a ClassCastException at runtime, while the expression List(1).asInstanceOf[List[String]] will not. In the latter example, because the type argument is erased as part of compilation it is not possible to check whether the contents of the list are of the requested type.

    returns

    the receiver object.

    Definition Classes
    Any
    Exceptions thrown
    ClassCastException

    if the receiver object is not an instance of the erasure of type T0.

  10. 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.

  11. def clone(): AnyRef

    Create a copy of the receiver object.

    Create a copy of the receiver object.

    The default implementation of the clone method is platform dependent.

    returns

    a copy of the receiver object.

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
    Note

    not specified by SLS as a member of AnyRef

  12. 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
  13. final def eq(arg0: AnyRef): Boolean

    Tests whether the argument (arg0) is a reference to the receiver object (this).

    Tests whether the argument (arg0) is a reference to the receiver object (this).

    The eq method implements an equivalence relation on non-null instances of AnyRef, and has three additional properties:

    • It is consistent: for any non-null instances x and y of type AnyRef, multiple invocations of x.eq(y) consistently returns true or consistently returns false.
    • For any non-null instance x of type AnyRef, x.eq(null) and null.eq(x) returns false.
    • null.eq(null) returns true.

    When overriding the equals or hashCode methods, it is important to ensure that their behavior is consistent with reference equality. Therefore, if two objects are references to each other (o1 eq o2), they should be equal to each other (o1 == o2) and they should hash to the same value (o1.hashCode == o2.hashCode).

    returns

    true if the argument is a reference to the receiver object; false otherwise.

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

    The equality method for reference types.

    The equality method for reference types. Default implementation delegates to eq.

    See also equals in scala.Any.

    returns

    true if the receiver object is equivalent to the argument; false otherwise.

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

  16. 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.

  17. 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.

  18. def finalize(): Unit

    Called by the garbage collector on the receiver object when there are no more references to the object.

    Called by the garbage collector on the receiver object when there are no more references to the object.

    The details of when and if the finalize method is invoked, as well as the interaction between finalize and non-local returns and exceptions, are all platform dependent.

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
    Note

    not specified by SLS as a member of AnyRef

  19. final def getClass(): Class[_]

    A representation that corresponds to the dynamic class of the receiver object.

    A representation that corresponds to the dynamic class of the receiver object.

    The nature of the representation is platform dependent.

    returns

    a representation that corresponds to the dynamic class of the receiver object.

    Definition Classes
    AnyRef → Any
    Note

    not specified by SLS as a member of AnyRef

  20. def hashCode(): Int

    The hashCode method for reference types.

    The hashCode method for reference types. See hashCode in scala.Any.

    returns

    the hash code value for this object.

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

    Test whether the dynamic type of the receiver object is T0.

    Test whether the dynamic type of the receiver object is T0.

    Note that the result of the test is modulo Scala's erasure semantics. Therefore the expression 1.isInstanceOf[String] will return false, while the expression List(1).isInstanceOf[List[String]] will return true. In the latter example, because the type argument is erased as part of compilation it is not possible to check whether the contents of the list are of the specified type.

    returns

    true if the receiver object is an instance of erasure of type T0; false otherwise.

    Definition Classes
    Any
  22. 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

  23. 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

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

    Repeatedly executes body.

    Repeatedly executes body.

    body

    the block to be executed

    Definition Classes
    Combinators
  25. 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
  26. 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

  27. 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
  28. final def ne(arg0: AnyRef): Boolean

    Equivalent to !(this eq that).

    Equivalent to !(this eq that).

    returns

    true if the argument is not a reference to the receiver object; false otherwise.

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

    Wakes up a single thread that is waiting on the receiver object's monitor.

    Wakes up a single thread that is waiting on the receiver object's monitor.

    Definition Classes
    AnyRef
    Note

    not specified by SLS as a member of AnyRef

  30. final def notifyAll(): Unit

    Wakes up all threads that are waiting on the receiver object's monitor.

    Wakes up all threads that are waiting on the receiver object's monitor.

    Definition Classes
    AnyRef
    Note

    not specified by SLS as a member of AnyRef

  31. 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

  32. 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

  33. 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 {}
      }
  34. 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")
      }
  35. 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

  36. def reply(): Unit

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

  37. def reply(msg: Any): Unit

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

  38. 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.

  39. 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 {}
      }
  40. 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.

  41. def sender: OutputChannel[Any]

    Returns the actor which sent the last received message.

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

    Definition Classes
    AnyRef
  43. def toString(): String

    Creates a String representation of this object.

    Creates a String representation of this object. The default representation is platform dependent. On the java platform it is the concatenation of the class name, "@", and the object's hashcode in hexadecimal.

    returns

    a String representation of the object.

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

    Unlinks self from actor from.

    Unlinks self from actor from.

    from

    the actor to unlink from

  45. final def wait(): Unit

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

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  47. 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