1 // Copyright 2003 Adam Megacz, see the COPYING file for licensing [GPL]
8 /** Implements cooperative multitasking */
9 public class Scheduler {
11 public static final Scheduler singleton = Platform.getScheduler();
12 protected Scheduler() { }
14 public static abstract class Task { public abstract void perform(); }
16 protected static Queue runnable = new Queue(50);
17 public static void add(Task t) { singleton.runnable.append(t); }
20 Task t = (Task)runnable.remove(true);
23 // FIXME: be smarter about this
24 for(int i=0; i<Surface.allSurfaces.size(); i++)
25 ((Surface)Surface.allSurfaces.elementAt(i)).render();
26 } catch (Exception e) {
27 Log.log(Scheduler.class, "Task threw an exception: " + e);
28 Log.log(Scheduler.class, e);