X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;ds=inline;f=src%2Forg%2Fxwt%2FScheduler.java;h=f4338582b011d6e97a675f6617f273903560a98c;hb=fa49b56b41be191e83bcf8222381fee2c4e0355b;hp=8a5cd3226d9f5d286abf80d23580d78e1276be69;hpb=2ccad2219888c9942f62ae8b4d4207f655690948;p=org.ibex.core.git diff --git a/src/org/xwt/Scheduler.java b/src/org/xwt/Scheduler.java index 8a5cd32..f433858 100644 --- a/src/org/xwt/Scheduler.java +++ b/src/org/xwt/Scheduler.java @@ -8,13 +8,34 @@ import org.xwt.util.*; /** Implements cooperative multitasking */ public class Scheduler { + // FIXME: prepending events messes with keysate -- make a "no re-ordering" invariant? + // Public API Exposed to org.xwt ///////////////////////////////////////////////// private static Scheduler singleton; public static interface Task { public abstract void perform() throws Exception; } + + /** adds a task to the back of the queue */ public static void add(Task t) { singleton.runnable.append(t); } + + /** adds a task to the front of the queue (guaranteed to run next) */ + public static void addAtFront(Task t) { singleton.runnable.prepend(t); } + public static void init() { if (singleton == null) (singleton = Platform.getScheduler()).run(); } + private static Task current = null; + public static Task current() { return current; } + + /** synchronizd so that we can safely call it from an event-delivery thread, in-context */ + public static synchronized void renderAll() { + for(int i=0; i