X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Forg%2Fxwt%2FScheduler.java;h=9e939a3d87f7a55c77971268342d403004b4278e;hb=de378041d5ca2aca1a2b5a31ef15ae90a86c977f;hp=a46c75c8722b0d3925d1696b2b6f936ce3081706;hpb=11fd362678d42aed89e4bc3cd0ce18e399ae48c4;p=org.ibex.core.git diff --git a/src/org/xwt/Scheduler.java b/src/org/xwt/Scheduler.java index a46c75c..9e939a3 100644 --- a/src/org/xwt/Scheduler.java +++ b/src/org/xwt/Scheduler.java @@ -1,4 +1,4 @@ -// Copyright 2003 Adam Megacz, see the COPYING file for licensing [GPL] +// Copyright 2004 Adam Megacz, see the COPYING file for licensing [GPL] package org.xwt; import java.util.*; @@ -10,39 +10,81 @@ public class Scheduler { // Public API Exposed to org.xwt ///////////////////////////////////////////////// - public static abstract class Task { public abstract void perform(); } + private static Scheduler singleton; + public static interface Task { public abstract void perform() throws Exception; } public static void add(Task t) { singleton.runnable.append(t); } - public static void init() { singleton.run(); } + public static void init() { if (singleton == null) (singleton = Platform.getScheduler()).run(); } + private static Task current = null; - // API which must be supported by subclasses ///////////////////////////////////// + private static volatile boolean rendering = false; + private static volatile boolean again = false; - protected Scheduler() { } + /** synchronizd so that we can safely call it from an event-delivery thread, in-context */ + public static void renderAll() { + if (rendering) { again = true; return; } + synchronized(Scheduler.class) { + try { + rendering = true; + do { + // FEATURE: this could be cleaner + again = false; + for(int i=0; i