further attempts to simplify/robustify Swing_Thread.now, to avoid spurious physical race conditions on Java 6 / Mac OS X;
--- 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] =