2003/11/03 00:08:26
[org.ibex.core.git] / src / org / xwt / Scheduler.java
index 95fd6bf..2cb7892 100644 (file)
@@ -5,24 +5,22 @@ import java.util.*;
 import org.xwt.js.*;
 import org.xwt.util.*;
 
-// FEATURE: reimplement Watcher
 /** Implements cooperative multitasking */
 public class Scheduler {
 
-    private static Scheduler singleton = new Scheduler();
-    public static void run() { singleton.do_run(); }
+    public static final Scheduler singleton = Platform.getScheduler();
     protected Scheduler() { }
 
-    public static abstract class Task implements Callback { public abstract Object call(Object o); }
-
-    private static Queue runnable = new Queue(50);
+    public static abstract class Task { public abstract void perform(); }
 
+    protected static Queue runnable = new Queue(50);
     public static void add(Task t) { singleton.runnable.append(t); }
-    public void do_run() {
+    public void run() {
         while(true) {
             Task t = (Task)runnable.remove(true);
             try {
-                t.call(null);
+                t.perform();
+                // FIXME: be smarter about this
                 for(int i=0; i<Surface.allSurfaces.size(); i++)
                     ((Surface)Surface.allSurfaces.elementAt(i)).render();
             } catch (Exception e) {