summaryrefslogtreecommitdiff
path: root/src/actors
diff options
context:
space:
mode:
authorPhilipp Haller <hallerp@gmail.com>2007-05-20 11:03:51 +0000
committerPhilipp Haller <hallerp@gmail.com>2007-05-20 11:03:51 +0000
commitd8e55969506c6db2ac21948128404ddf938d4b8c (patch)
treedca9d768d8288a4e266b67978c290e7c5e2a7288 /src/actors
parent9ddd12335eb95435f76a0766d165b20ab8424587 (diff)
downloadscala-d8e55969506c6db2ac21948128404ddf938d4b8c.tar.gz
scala-d8e55969506c6db2ac21948128404ddf938d4b8c.tar.bz2
scala-d8e55969506c6db2ac21948128404ddf938d4b8c.zip
Fixed stack overflow bug.
Diffstat (limited to 'src/actors')
-rw-r--r--src/actors/scala/actors/Actor.scala33
1 files changed, 16 insertions, 17 deletions
diff --git a/src/actors/scala/actors/Actor.scala b/src/actors/scala/actors/Actor.scala
index 6e3179113c..7b0f064836 100644
--- a/src/actors/scala/actors/Actor.scala
+++ b/src/actors/scala/actors/Actor.scala
@@ -171,7 +171,7 @@ object Actor {
}
implicit def mkBody[a](body: => a) = new Body[a] {
- def andThen[b](other: => b): Nothing = seq(body, other)
+ def andThen[b](other: => b): Nothing = self.seq(body, other)
}
/**
@@ -183,22 +183,6 @@ object Actor {
def loop(body: => Unit): Nothing = body andThen loop(body)
/**
- * Causes <code>self</code> to execute <code>first</code>
- * followed by <code>next</code>.
- *
- * @param first the first code block to be executed
- * @param next the second code block to be executed
- */
- def seq[a, b](first: => a, next: => b): Nothing = {
- val s = self
- val killNext = s.kill
- s.kill = () => { s.kill = killNext; next; s.kill() }
- first
- s.kill()
- throw new ExitActorException
- }
-
- /**
* Links <code>self</code> to actor <code>to</code>.
*
* @param to the actor to link to
@@ -617,6 +601,21 @@ trait Actor extends OutputChannel[Any] {
this
}
+ private def seq[a, b](first: => a, next: => b): Nothing = {
+ val s = Actor.self
+ val killNext = s.kill
+ s.kill = () => { s.kill = killNext; next; s.kill() }
+ first
+
+ // to avoid stack overflow: instead of directly executing,
+ // schedule task that executes s.kill()
+ scheduleActor({
+ case 'kill => Actor.self.kill()
+ }, 'kill)
+
+ throw new ExitActorException
+ }
+
/**
* Repeatedly execute <code>body</code>.
*