|
Scala Library Documentation
|
|
scala/actors/Actor.scala]
object
Actor
extends AnyRefActor object provides functions for the definition of
actors, as well as all actor operations, such as
receive, react, reply,
etc.| Value Summary | |
val
|
tl : ThreadLocal |
| Method Summary | |
def
|
?
: Any
Receives the next message from the mailbox of the current actor
self. |
def
|
actor
(body : => Unit) : Actor
This function is used for the definition of actors. The following example demonstrates its usage:
import scala.actors.Actor._
...
val a = actor {
...
}
|
def
|
continue : Unit |
def
|
eventloop (f : PartialFunction[Any, Unit]) : Nothing |
def
|
exit
: Nothing
Terminates execution of
For each linked actor |
def
|
exit
(reason : AnyRef) : Nothing
Terminates execution of
For each linked actor
For each linked actor |
def
|
link
(to : Actor) : Actor
Links
self to actor to. |
def
|
link
(body : => Unit) : Actor
Links
self to actor defined by body. |
def
|
loop
(body : => Unit) : Nothing
Causes
self to repeatedly execute
body. |
implicit def
|
mkBody [a](body : => a) : Body[a] |
def
|
react
(f : PartialFunction[Any, Unit]) : Nothing
Lightweight variant of
receive.
Actions in f have to contain the rest of the
computation of self, as this method will never
return. |
def
|
reactWithin
(msec : Long)(f : PartialFunction[Any, Unit]) : Nothing
Lightweight variant of
receiveWithin.
Actions in f have to contain the rest of the
computation of self, as this method will never
return. |
def
|
receive
[a](f : PartialFunction[Any, a]) : a
Receives a message from the mailbox of
self. Blocks if no message matching any of the
cases of f can be received. |
def
|
receiveWithin
[R](msec : Long)(f : PartialFunction[Any, R]) : R
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. |
def
|
reply
: Unit
Send
() to the actor waiting in a call to
!?. |
def
|
reply
(msg : Any) : Unit
Send
msg to the actor waiting in a call to
!?. |
def
|
resetProxy
: Unit
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. |
def
|
self
: Actor
Returns the currently executing actor. Should be used instead
of
this in all blocks of code executed by
actors. |
def
|
sender
: Actor
Returns the actor which sent the last received message.
|
def
|
unlink
(from : Actor) : 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 |
| Class Summary | |
trait
|
Body
[a] extends AnyRef
|
| Value Details |
| Method Details |
def
self : Actor
this in all blocks of code executed by
actors.
def
resetProxy : Unit
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.This function is used for the definition of actors.
The following example demonstrates its usage:
import scala.actors.Actor._
...
val a = actor {
...
}
body - the code block to be executed by the newly created actor
def
? : Any
self.
def
receive[a](f : PartialFunction[Any, a]) : a
self. Blocks if no message matching any of the
cases of f can be received.f - a partial function specifying patterns and actions
def
receiveWithin[R](msec : Long)(f : PartialFunction[Any, R]) : R
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 timeoutf - a partial function specifying patterns and actions
def
react(f : PartialFunction[Any, Unit]) : Nothing
receive.
Actions in f have to contain the rest of the
computation of self, as this method will never
return.f - a partial function specifying patterns and actions
def
reactWithin(msec : Long)(f : PartialFunction[Any, Unit]) : Nothing
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 timeoutf - a partial function specifying patterns and actions
def
eventloop(f : PartialFunction[Any, Unit]) : Nothing
def
sender : Actor
msg to the actor waiting in a call to
!?.
def
reply : Unit
() to the actor waiting in a call to
!?.self to repeatedly execute
body.body - the code block to be executedself to actor to.to - the actor to link toself to actor defined by body.body - ...self from actor from.from - the actor to unlink 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
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.
def
continue : Unit
|
Scala Library Documentation
|
|