Receives the next message from the mailbox of the current actor
self
Receives the next message from the mailbox of the current actor
self
.
This is a factory method for creating actors
This is a factory method for creating actors.
The following example demonstrates its usage:
import scala.actors.Actor._ ... val a = actor { ... }
the code block to be executed by the newly created actor
the newly created actor. Note that it is automatically started.
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.
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:
x
of type Any
,
x.equals(x)
should return true
.x
and y
of type
Any
, x.equals(y)
should return true
if and only
if y.equals(x)
returns true
.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)
).
the object to compare against this object for equality.
true
if the receiver object is equivalent to the argument; false
otherwise.
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
.
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
.
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.
Links self
to the actor defined by body
Links self
to the actor defined by body
.
the body of the actor to link to
the parameter actor
Links self
to actor to
Causes self
to repeatedly execute
body
Causes self
to repeatedly execute
body
while the condition
cond
is true
Causes self
to repeatedly execute
body
while the condition
cond
is true
.
the condition to test
the code block to be executed
Returns the number of messages in self
's mailbox
Returns the number of messages in self
's mailbox
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 partial function specifying patterns and actions
this function never returns
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.
the time span before timeout
a partial function specifying patterns and actions
this function never returns
This is a factory method for creating actors whose
body is defined using a Responder
This is a factory method for creating actors whose
body is defined using a Responder
.
The following example demonstrates its usage:
import scala.actors.Actor._ import Responder.exec ... val a = reactor { for { res <- b !! MyRequest; if exec(println("result: "+res)) } yield {} }
the Responder
to be executed by the newly created actor
the newly created actor. Note that it is automatically started.
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.
a partial function specifying patterns and actions
the result of processing the received message
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.
the time span before timeout
a partial function specifying patterns and actions
the result of processing the received message
Send ()
to the actor waiting in a call to
!?
Send ()
to the actor waiting in a call to
!?
.
Send msg
to the actor waiting in a call to
!?
Send msg
to the actor waiting in a call to
!?
.
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.
Converts a synchronous event-based operation into
an asynchronous Responder
Converts a synchronous event-based operation into
an asynchronous Responder
.
The following example demonstrates its usage:
val adder = reactor { for { _ <- respondOn(react) { case Add(a, b) => reply(a+b) } } yield {} }
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 the actor which sent the last received message
Returns the actor which sent the last received message.
Returns a string representation of the object
Returns a string representation of the object.
The default representation is platform dependent.
Unlinks self
from actor from
The
Actor
object provides functions for the definition of actors, as well as actor operations, such asreceive
,react
,reply
, etc.