scala.actors

class Channel

[source: scala/actors/Channel.scala]

class Channel[Msg]
extends InputChannel[Msg] with OutputChannel[Msg] with AnyRef
This class provides a means for typed communication among actors. Only the actor creating an instance of a Channel may receive from it.
Version
0.9.9
Author
Philipp Haller
Additional Constructor Summary
def this (recv : Actor) : Channel[Msg]
Method Summary
def ! (msg : Msg) : Unit
Sends a message to this Channel.
def !? (msg : Msg) : Any
Sends a message to this Channel and awaits reply.
def !? (msec : Long, msg : Msg) : Option[Any]
Sends a message to this Channel and awaits reply within a certain time span.
def ? : Msg
Receives the next message from this Channel.
def forward (msg : Msg) : Unit
Forwards msg to this keeping the last sender as sender instead of self.
def react (f : PartialFunction[Msg, Unit]) : Nothing
Receives a message from this Channel.
def reactWithin (msec : Long)(f : PartialFunction[Any, Unit]) : Nothing
Receives a message from this Channel within a certain time span.
def receive [R](f : PartialFunction[Msg, R]) : R
Receives a message from this Channel.
def receiveWithin [R](msec : Long)(f : PartialFunction[Any, R]) : R
Receives a message from this Channel within a certain time span.
def receiver : Actor
Returns the Actor that is receiving from this OutputChannel.
Methods inherited from AnyRef
getClass, hashCode, equals, clone, toString, notify, notifyAll, wait, wait, wait, finalize, ==, !=, eq, ne, synchronized
Methods inherited from Any
==, !=, isInstanceOf, asInstanceOf
Additional Constructor Details
def this(recv : Actor) : Channel[Msg]

Method Details
def receiver : Actor
Returns the Actor that is receiving from this OutputChannel.
Overrides
OutputChannel.receiver

def !(msg : Msg) : Unit
Sends a message to this Channel.
Parameters
msg - the message to be sent
Overrides
OutputChannel.!

def forward(msg : Msg) : Unit
Forwards msg to this keeping the last sender as sender instead of self.
Overrides
OutputChannel.forward

def receive[R](f : PartialFunction[Msg, R]) : R
Receives a message from this Channel.
Parameters
f - a partial function with message patterns and actions
Returns
result of processing the received value
Overrides
InputChannel.receive

def ? : Msg
Receives the next message from this Channel.
Overrides
InputChannel.?

def receiveWithin[R](msec : Long)(f : PartialFunction[Any, R]) : R
Receives a message from this Channel within a certain time span.
Parameters
msec - the time span before timeout
f - a partial function with message patterns and actions
Returns
result of processing the received value
Overrides
InputChannel.receiveWithin

def react(f : PartialFunction[Msg, Unit]) : Nothing
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.

Parameters
f - a partial function with message patterns and actions
Overrides
InputChannel.react

def reactWithin(msec : Long)(f : PartialFunction[Any, Unit]) : Nothing
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.

Parameters
msec - the time span before timeout
f - a partial function with message patterns and actions
Overrides
InputChannel.reactWithin

def !?(msg : Msg) : Any
Sends a message to this Channel and awaits reply.
Parameters
msg - the message to be sent
Returns
the reply

def !?(msec : Long, msg : Msg) : Option[Any]
Sends a message to this Channel and awaits reply within a certain time span.
Parameters
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