# HG changeset patch # User wenzelm # Date 1337944750 -7200 # Node ID 880f1693299a0d1039704aa873366768c7f730ca # Parent 3ffd885abe00660af2ac1786766e04e5b89b475d further attempts to simplify/robustify Swing_Thread.now, to avoid spurious physical race conditions on Java 6 / Mac OS X; diff -r 3ffd885abe00 -r 880f1693299a src/Pure/System/swing_thread.scala --- a/src/Pure/System/swing_thread.scala Fri May 25 11:18:32 2012 +0200 +++ b/src/Pure/System/swing_thread.scala Fri May 25 13:19:10 2012 +0200 @@ -24,11 +24,12 @@ def now[A](body: => A): A = { - @volatile var result: Option[Exn.Result[A]] = None - if (SwingUtilities.isEventDispatchThread()) { result = Some(Exn.capture(body)) } - else - SwingUtilities.invokeAndWait(new Runnable { def run = { result = Some(Exn.capture(body)) } }) - Exn.release(result.get) + if (SwingUtilities.isEventDispatchThread()) body + else { + lazy val result = { assert(); Exn.capture(body) } + SwingUtilities.invokeAndWait(new Runnable { def run = result }) + Exn.release(result) + } } def future[A](body: => A): Future[A] =