summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPhilipp Haller <hallerp@gmail.com>2007-02-02 15:20:05 +0000
committerPhilipp Haller <hallerp@gmail.com>2007-02-02 15:20:05 +0000
commitffa9da234de5621dfc6d8e760b5368ca68a6520f (patch)
treee425d7a2f37fb8f7ed0865fcd9caf3c6c68f4a4b /src
parent7cc5c06947e40236ee16a6a09d3de524183fda86 (diff)
downloadscala-ffa9da234de5621dfc6d8e760b5368ca68a6520f.tar.gz
scala-ffa9da234de5621dfc6d8e760b5368ca68a6520f.tar.bz2
scala-ffa9da234de5621dfc6d8e760b5368ca68a6520f.zip
scala.actors: exit now works inside loop.
Diffstat (limited to 'src')
-rw-r--r--src/actors/scala/actors/Actor.scala22
-rw-r--r--src/actors/scala/actors/Channel.scala5
2 files changed, 10 insertions, 17 deletions
diff --git a/src/actors/scala/actors/Actor.scala b/src/actors/scala/actors/Actor.scala
index 1da3c683f7..c4ebeef27b 100644
--- a/src/actors/scala/actors/Actor.scala
+++ b/src/actors/scala/actors/Actor.scala
@@ -191,12 +191,7 @@ object Actor {
*
* @param body the code block to be executed
*/
- def loop(body: => Unit): Unit = {
- val s = self
- s.kill = () => { body; s.kill() }
- body
- exit("normal")
- }
+ def loop(body: => Unit): Nothing = body andThen loop(body)
/**
* Causes <code>self</code> to execute <code>first</code>
@@ -208,7 +203,7 @@ object Actor {
def seq[a, b](first: => a, next: => b): Nothing = {
val s = self
val killNext = s.kill
- s.kill = () => { s.kill = killNext; next; s.kill() }
+ s.kill = () => { s.kill = killNext; next; exit("normal") }
first
exit("normal")
}
@@ -439,7 +434,7 @@ trait Actor extends OutputChannel[Any] {
def reply(msg: Any): Unit = session ! msg
- private var rc = new Channel[Any]
+ private var rc = new Channel[Any](this)
def getReplyChannel = rc
def freshReply() = { rc = new Channel[Any]; rc }
@@ -596,7 +591,7 @@ trait Actor extends OutputChannel[Any] {
* </p>
*/
def exit(reason: String): Nothing = {
- kill()
+ if (reason.equals("normal")) kill()
// links
if (!links.isEmpty) {
exitReason = reason
@@ -605,14 +600,7 @@ trait Actor extends OutputChannel[Any] {
throw new ExitActorException
}
- def exit(): Nothing = {
- kill()
- // links
- if (!links.isEmpty) {
- exitLinked()
- }
- throw new ExitActorException
- }
+ def exit(): Nothing = exit("normal")
// Assume !links.isEmpty
private[actors] def exitLinked() {
diff --git a/src/actors/scala/actors/Channel.scala b/src/actors/scala/actors/Channel.scala
index cee8ab5642..fc473d76cc 100644
--- a/src/actors/scala/actors/Channel.scala
+++ b/src/actors/scala/actors/Channel.scala
@@ -46,6 +46,11 @@ class Channel[Msg] extends InputChannel[Msg] with OutputChannel[Msg] {
Actor.tl.get.asInstanceOf[Actor]
}
+ private[actors] def this(recv: Actor) = {
+ this()
+ receiver = recv
+ }
+
/**
* Sends a message to this <code>Channel</code>.
*