# HG changeset patch # User wenzelm # Date 1263075744 -3600 # Node ID 68716caa77458a2d14d133f3a75efc4012a01635 # Parent 13e9f1f4acd95abae7ec533a578055a412bac936 Swing_Thread.future: plain Future.value if this is already Swing; diff -r 13e9f1f4acd9 -r 68716caa7745 src/Pure/General/swing_thread.scala --- a/src/Pure/General/swing_thread.scala Sat Jan 09 18:23:02 2010 +0100 +++ b/src/Pure/General/swing_thread.scala Sat Jan 09 23:22:24 2010 +0100 @@ -29,9 +29,14 @@ result.get } - def future[A](body: => A): Future[A] = Future.fork { now(body) } + def future[A](body: => A): Future[A] = + { + if (SwingUtilities.isEventDispatchThread()) Future.value(body) + else Future.fork { now(body) } + } - def later(body: => Unit) { + def later(body: => Unit) + { if (SwingUtilities.isEventDispatchThread()) body else SwingUtilities.invokeLater(new Runnable { def run = body }) }