# HG changeset patch # User wenzelm # Date 1251917344 -7200 # Node ID 4ab2292e452af5a1e9adbce12e350ca66451210d # Parent 457ea5ddbb9bba079c91be4f0e3e034230a9f025 explicit checks; diff -r 457ea5ddbb9b -r 4ab2292e452a src/Pure/General/swing_thread.scala --- a/src/Pure/General/swing_thread.scala Wed Sep 02 17:33:25 2009 +0200 +++ b/src/Pure/General/swing_thread.scala Wed Sep 02 20:49:04 2009 +0200 @@ -13,17 +13,23 @@ object Swing_Thread { + /* checks */ + + def assert() = Predef.assert(SwingUtilities.isEventDispatchThread()) + def require() = Predef.require(SwingUtilities.isEventDispatchThread()) + + /* main dispatch queue */ def now[A](body: => A): A = { var result: Option[A] = None - if (SwingUtilities.isEventDispatchThread) { result = Some(body) } + if (SwingUtilities.isEventDispatchThread()) { result = Some(body) } else SwingUtilities.invokeAndWait(new Runnable { def run = { result = Some(body) } }) result.get } def later(body: => Unit) { - if (SwingUtilities.isEventDispatchThread) body + if (SwingUtilities.isEventDispatchThread()) body else SwingUtilities.invokeLater(new Runnable { def run = body }) }