Scala Library
|
|
scala/actors/Actor.scala
]
trait
Actor
extends
AbstractActorThis class provides an implementation of event-based actors. The main ideas of our approach are explained in the two papers
Value Summary | |
protected val
|
mailbox : MessageQueue |
var
|
trapExit : Boolean |
Method Summary | |
def
|
!
(msg : Any) : Unit
Sends
msg to this actor (asynchronous). |
def
|
!!
[A](msg : Any, f : PartialFunction[Any, A]) : Future[A]
Sends
msg to this actor and immediately
returns a future representing the reply value.
The reply is post-processed using the partial function
f . This also allows to recover a more
precise type for the reply value. |
def
|
!!
(msg : Any) : Future[Any]
Sends
msg to this actor and immediately
returns a future representing the reply value. |
def
|
!?
(msg : Any) : Any
Sends
msg to this actor and awaits reply
(synchronous). |
def
|
!?
(msec : Long, msg : Any) : Option[Any]
Sends
msg to this actor and awaits reply
(synchronous) within msec milliseconds. |
def
|
?
: Any
Receives the next message from this actor's mailbox.
|
abstract def
|
act
: Unit
The behavior of an actor is specified by implementing this
abstract method. Note that the preferred way to create actors
is through the
actor method
defined in object Actor . |
def
|
exit
: Nothing
Terminates with exit reason
'normal . |
def
|
exit (reason : AnyRef) : Nothing |
def
|
forward
(msg : Any) : Unit
Forwards
msg to this actor (asynchronous). |
def
|
link
(body : => Unit) : Actor
Links
self to actor defined by body . |
def
|
link
(to : AbstractActor) : AbstractActor
Links
self to actor to . |
def
|
mailboxSize
: Int
Returns the number of messages in this actor's mailbox
|
def
|
react
(f : PartialFunction[Any, Unit]) : Nothing
Receives a message from this actor's mailbox.
|
def
|
reactWithin
(msec : Long)(f : PartialFunction[Any, Unit]) : Nothing
Receives a message from this actor's mailbox within a certain
time span.
|
def
|
receive
[R](f : PartialFunction[Any, R]) : R
Receives a message from this actor's mailbox.
|
def
|
receiveWithin
[R](msec : Long)(f : PartialFunction[Any, R]) : R
Receives a message from this actor's mailbox within a certain
time span.
|
def
|
receiver
: Actor
Returns the
Actor that is
receiving from this OutputChannel . |
def
|
reply
(msg : Any) : Unit
Replies with
msg to the sender. |
protected def
|
scheduleActor (f : PartialFunction[Any, Unit], msg : Any) : Unit |
protected def
|
scheduler : IScheduler |
def
|
send
(msg : Any, replyTo : OutputChannel[Any]) : Unit
Sends
msg to this actor (asynchronous) supplying
explicit reply destination. |
def
|
sender : OutputChannel[Any] |
def
|
start
: Actor
Starts this actor.
|
def
|
unlink
(from : AbstractActor) : 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 |
Value Details |
Method Details |
protected
def
scheduler : IScheduler
def
mailboxSize : Int
def
send(msg : Any, replyTo : OutputChannel[Any]) : Unit
msg
to this actor (asynchronous) supplying
explicit reply destination.msg -
the message to sendreplyTo -
the reply destination
def
receive[R](f : PartialFunction[Any, R]) : R
f -
a partial function with message patterns and actions
def
receiveWithin[R](msec : Long)(f : PartialFunction[Any, R]) : R
msec -
the time span before timeoutf -
a partial function with message patterns and actions
def
react(f : PartialFunction[Any, Unit]) : Nothing
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
def
reactWithin(msec : Long)(f : PartialFunction[Any, Unit]) : Nothing
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 timeoutf -
a partial function with message patterns and actionsabstract
def
act : Unit
actor
method
defined in object Actor
.msg
to this actor (asynchronous).msg
to this actor (asynchronous).msg
to this actor and awaits reply
(synchronous).msg -
the message to be sentmsg
to this actor and awaits reply
(synchronous) within msec
milliseconds.msec -
the time span before timeoutmsg -
the message to be sentNone
in case of timeout, otherwise Some(x)
where x
is the replymsg
to this actor and immediately
returns a future representing the reply value.msg
to this actor and immediately
returns a future representing the reply value.
The reply is post-processed using the partial function
f
. This also allows to recover a more
precise type for the reply value.msg
to the sender.
def
? : Any
def
sender : OutputChannel[Any]
def
receiver : Actor
Actor
that is
receiving from this OutputChannel
.protected
def
scheduleActor(f : PartialFunction[Any, Unit], msg : Any) : Unit
def
start : Actor
def
link(to : AbstractActor) : AbstractActor
self
to actor to
.to -
...self
to actor defined by body
.
def
unlink(from : AbstractActor) : Unit
self
from actor from
.
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
'normal
.
Scala Library
|
|