// Copyright 2004 Adam Megacz, see the COPYING file for licensing [GPL]
-package org.ibex;
+package org.ibex.util;
import java.io.IOException;
import org.ibex.js.*;
import org.ibex.util.*;
+import org.ibex.graphics.*;
+import org.ibex.plat.*;
/** Implements cooperative multitasking */
public class Scheduler {
// Public API Exposed to org.ibex /////////////////////////////////////////////////
private static Scheduler singleton;
- public static interface Task { public abstract void perform() throws IOException, JSExn; }
- public static void add(Task t) { Log.debug(Scheduler.class, "scheduling " + t); Scheduler.runnable.append(t); }
+ private static String taskDesc(Task t) { return t instanceof JS ? JS.debugToString((JS)t) : t.toString(); }
+ public static void add(Task t) { Log.debug(Scheduler.class, "scheduling " + taskDesc(t)); Scheduler.runnable.append(t); }
public static void init() { if (singleton == null) (singleton = Platform.getScheduler()).run(); }
private static Task current = null;
* Surface.renderAll() more often than that if it so chooses.
*/
public void run() { defaultRun(); }
- protected Scheduler() { }
+ public Scheduler() { }
// Default Implementation //////////////////////////////////////////////////////
s._mousey = s.mousey;
}
}
- Log.debug(Scheduler.class, "performing " + current);
+ Log.debug(Scheduler.class, "performing " + taskDesc(current));
current.perform();
}
renderAll();