diff options
author | Philipp Haller <hallerp@gmail.com> | 2009-10-01 09:46:35 +0000 |
---|---|---|
committer | Philipp Haller <hallerp@gmail.com> | 2009-10-01 09:46:35 +0000 |
commit | d3640222361fa03d13cb0149f0c06fbde87eb4e1 (patch) | |
tree | d6cfa517b15bf20db3c91f86b368cc39d4928555 | |
parent | efa181e5777fe72ce686bc8a3671b50fa3e601de (diff) | |
download | scala-d3640222361fa03d13cb0149f0c06fbde87eb4e1.tar.gz scala-d3640222361fa03d13cb0149f0c06fbde87eb4e1.tar.bz2 scala-d3640222361fa03d13cb0149f0c06fbde87eb4e1.zip |
Fixed thread-visibility issues causing scala-ni...
Fixed thread-visibility issues causing scala-nightly-args 387 to fail.
-rw-r--r-- | src/actors/scala/actors/Actor.scala | 1 | ||||
-rw-r--r-- | src/actors/scala/actors/Reactor.scala | 7 | ||||
-rw-r--r-- | src/actors/scala/actors/ReplyReactor.scala | 1 |
3 files changed, 9 insertions, 0 deletions
diff --git a/src/actors/scala/actors/Actor.scala b/src/actors/scala/actors/Actor.scala index 26b4661170..057436a514 100644 --- a/src/actors/scala/actors/Actor.scala +++ b/src/actors/scala/actors/Actor.scala @@ -390,6 +390,7 @@ trait Actor extends AbstractActor with ReplyReactor with ReplyableActor { * the invocation of send to the place where the thread of * the receiving actor resumes inside receive/receiveWithin. */ + @volatile private var received: Option[Any] = None /* This option holds a TimerTask when the actor waits in a diff --git a/src/actors/scala/actors/Reactor.scala b/src/actors/scala/actors/Reactor.scala index 63c9ff32bd..a3e44d4d2c 100644 --- a/src/actors/scala/actors/Reactor.scala +++ b/src/actors/scala/actors/Reactor.scala @@ -27,6 +27,7 @@ trait Reactor extends OutputChannel[Any] { /* If the actor waits in a react, continuation holds the * message handler that react was called with. */ + @volatile private[actors] var continuation: PartialFunction[Any, Unit] = null /* Whenever this Actor executes on some thread, waitingFor is @@ -37,6 +38,8 @@ trait Reactor extends OutputChannel[Any] { * thread. */ private[actors] val waitingForNone = (m: Any) => false + + // guarded by lock of this private[actors] var waitingFor: Any => Boolean = waitingForNone /** @@ -82,6 +85,9 @@ trait Reactor extends OutputChannel[Any] { private[actors] def makeReaction(fun: () => Unit): Runnable = new ReactorTask(this, fun) + /* Note that this method is called without holding a lock. + * Therefore, to read an up-to-date continuation, it must be @volatile. + */ private[actors] def resumeReceiver(item: (Any, OutputChannel[Any]), onSameThread: Boolean) { // assert continuation != null if (onSameThread) @@ -166,6 +172,7 @@ trait Reactor extends OutputChannel[Any] { * built on top of `seq`. Note that the only invocation of * `kill` is supposed to be inside `Reaction.run`. */ + @volatile private[actors] var kill: () => Unit = () => { exit() } diff --git a/src/actors/scala/actors/ReplyReactor.scala b/src/actors/scala/actors/ReplyReactor.scala index 9e59c4956d..db7a74aba5 100644 --- a/src/actors/scala/actors/ReplyReactor.scala +++ b/src/actors/scala/actors/ReplyReactor.scala @@ -24,6 +24,7 @@ trait ReplyReactor extends Reactor { /* A list of the current senders. The head of the list is * the sender of the message that was received last. */ + @volatile private[actors] var senders: List[OutputChannel[Any]] = Nil |