summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/actors/scala/actors/Actor.scala12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/actors/scala/actors/Actor.scala b/src/actors/scala/actors/Actor.scala
index 8c98f45d41..db1c52ad44 100644
--- a/src/actors/scala/actors/Actor.scala
+++ b/src/actors/scala/actors/Actor.scala
@@ -432,8 +432,8 @@ trait Actor extends AbstractActor {
*/
def receive[R](f: PartialFunction[Any, R]): R = {
assert(Actor.self == this, "receive from channel belonging to other actor")
- if (shouldExit) exit() // links
this.synchronized {
+ if (shouldExit) exit() // links
val qel = mailbox.extractFirst((m: Any) => f.isDefinedAt(m))
if (null eq qel) {
waitingFor = f.isDefinedAt
@@ -459,8 +459,9 @@ trait Actor extends AbstractActor {
*/
def receiveWithin[R](msec: Long)(f: PartialFunction[Any, R]): R = {
assert(Actor.self == this, "receive from channel belonging to other actor")
- if (shouldExit) exit() // links
this.synchronized {
+ if (shouldExit) exit() // links
+
// first, remove spurious TIMEOUT message from mailbox if any
val spurious = mailbox.extractFirst((m: Any) => m == TIMEOUT)
@@ -510,8 +511,8 @@ trait Actor extends AbstractActor {
*/
def react(f: PartialFunction[Any, Unit]): Nothing = {
assert(Actor.self == this, "react on channel belonging to other actor")
- if (shouldExit) exit() // links
this.synchronized {
+ if (shouldExit) exit() // links
val qel = mailbox.extractFirst((m: Any) => f.isDefinedAt(m))
if (null eq qel) {
waitingFor = f.isDefinedAt
@@ -537,8 +538,8 @@ trait Actor extends AbstractActor {
*/
def reactWithin(msec: Long)(f: PartialFunction[Any, Unit]): Nothing = {
assert(Actor.self == this, "react on channel belonging to other actor")
- if (shouldExit) exit() // links
this.synchronized {
+ if (shouldExit) exit() // links
// first, remove spurious TIMEOUT message from mailbox if any
val spurious = mailbox.extractFirst((m: Any) => m == TIMEOUT)
@@ -1007,6 +1008,9 @@ trait Actor extends AbstractActor {
this.synchronized {
shouldExit = true
exitReason = reason
+ // resume this Actor in a way that
+ // causes it to exit
+ // (because shouldExit == true)
if (isSuspended)
resumeActor()
else if (isDetached)