src/Pure/System/jfx_thread.scala
changeset 49065 8ead9e8b15fb
child 49066 1067a639d42a
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/Pure/System/jfx_thread.scala	Sun Sep 02 19:26:05 2012 +0200
@@ -0,0 +1,28 @@
+/*  Title:      Pure/System/jfx_thread.scala
+    Module:     PIDE
+    Author:     Makarius
+
+Evaluation within the Java FX application thread.
+*/
+
+package isabelle
+
+import javafx.application.{Platform => JFX_Platform}
+
+
+object JFX_Thread
+{
+  /* checks */
+
+  def assert() = Predef.assert(JFX_Platform.isFxApplicationThread())
+  def require() = Predef.require(JFX_Platform.isFxApplicationThread())
+
+
+  /* asynchronous context switch */
+
+  def later(body: => Unit)
+  {
+    if (JFX_Platform.isFxApplicationThread()) body
+    else JFX_Platform.runLater(new Runnable { def run = body })
+  }
+}