scala.actors

Channel

class Channel[Msg] extends InputChannel[Msg] with OutputChannel[Msg]

This class provides a means for typed communication among actors. Only the actor creating an instance of a Channel may receive from it.

Inherits

  1. OutputChannel
  2. AbstractReactor
  3. InputChannel
  4. AnyRef
  5. Any

Value Members

  1. def !(msg: Msg): Unit

    Sends a message to this Channel

    Sends a message to this Channel.

    msg

    the message to be sent

  2. def !?(msec: Long, msg: Msg): Option[Any]

    Sends a message to this Channel and awaits reply within a certain time span

    Sends a message to this Channel and awaits reply within a certain time span.

    msec

    the time span before timeout

    msg

    the message to be sent

    returns

    None in case of timeout, otherwise Some(x) where x is the reply

  3. def !?(msg: Msg): Any

    Sends a message to this Channel and awaits reply

    Sends a message to this Channel and awaits reply.

    msg

    the message to be sent

    returns

    the reply

  4. def ?: Msg

    Receives the next message from this Channel

    Receives the next message from this Channel.

  5. def equals(arg0: Any): Boolean

    This method is used to compare the receiver object (this) with the argument object (arg0) for equivalence

    This method is used to compare the receiver object (this) with the argument object (arg0) for equivalence.

    The default implementations of this method is an equivalence relation:

    • It is reflexive: for any instance x of type Any, x.equals(x) should return true.
    • It is symmetric: for any instances x and y of type Any, x.equals(y) should return true if and only if y.equals(x) returns true.
    • It is transitive: for any instances x, y, and z of type AnyRef if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.

    If you override this method, you should verify that your implementation remains an equivalence relation. Additionally, when overriding this method it is often necessary to override hashCode to ensure that objects that are "equal" (o1.equals(o2) returns true) hash to the same Int (o1.hashCode.equals(o2.hashCode)).

    arg0

    the object to compare against this object for equality.

    returns

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

    definition classes: AnyRef ⇐ Any
  6. def forward(msg: Msg): Unit

    Forwards msg to this keeping the last sender as sender instead of self

    Forwards msg to this keeping the last sender as sender instead of self.

  7. def hashCode(): Int

    Returns a hash code value for the object

    Returns a hash code value for the object.

    The default hashing algorithm is platform dependent.

    Note that it is allowed for two objects to have identical hash codes (o1.hashCode.equals(o2.hashCode)) yet not be equal (o1.equals(o2) returns false). A degenerate implementation could always return 0. However, it is required that if two objects are equal (o1.equals(o2) returns true) that they have identical hash codes (o1.hashCode.equals(o2.hashCode)). Therefore, when overriding this method, be sure to verify that the behavior is consistent with the equals method.

    definition classes: AnyRef ⇐ Any
  8. def react(f: PartialFunction[Msg, Unit]): Nothing

    Receives a message from this Channel

    Receives a message from this Channel.

    This method never returns. Therefore, the rest of the computation has to be contained in the actions of the partial function.

    f

    a partial function with message patterns and actions

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

    Receives a message from this Channel within a certain time span

    Receives a message from this Channel within a certain time span.

    This method never returns. Therefore, the rest of the computation has to be contained in the actions of the partial function.

    msec

    the time span before timeout

    f

    a partial function with message patterns and actions

  10. def receive[R](f: PartialFunction[Msg, R]): R

    Receives a message from this Channel

    Receives a message from this Channel.

    f

    a partial function with message patterns and actions

    returns

    result of processing the received value

  11. def receiveWithin[R](msec: Long)(f: PartialFunction[Any, R]): R

    Receives a message from this Channel within a certain time span

    Receives a message from this Channel within a certain time span.

    msec

    the time span before timeout

    f

    a partial function with message patterns and actions

    returns

    result of processing the received value

  12. val receiver: Actor

    Returns the Reactor that is receiving from this OutputChannel

    Returns the Reactor that is receiving from this OutputChannel.

  13. def send(msg: Msg, replyTo: OutputChannel[Any]): Unit

    Sends a message to this Channel (asynchronous) supplying explicit reply destination

    Sends a message to this Channel (asynchronous) supplying explicit reply destination.

    msg

    the message to send

    replyTo

    the reply destination

  14. def toString(): String

    Returns a string representation of the object

    Returns a string representation of the object.

    The default representation is platform dependent.

    definition classes: AnyRef ⇐ Any

Instance constructors

  1. new Channel()

  2. new Channel(receiver: Actor)