X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Forg%2Fxwt%2FScheduler.java;h=9e939a3d87f7a55c77971268342d403004b4278e;hb=de378041d5ca2aca1a2b5a31ef15ae90a86c977f;hp=1f57fe7c9c8976240c1874be5ddb07bad7c22cdb;hpb=a060cc5025b58e8d3e319aefa6ae44fe7c6182ad;p=org.ibex.core.git diff --git a/src/org/xwt/Scheduler.java b/src/org/xwt/Scheduler.java index 1f57fe7..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.*; @@ -11,20 +11,44 @@ public class Scheduler { // Public API Exposed to org.xwt ///////////////////////////////////////////////// private static Scheduler singleton; - public static abstract class Task { public abstract void perform() throws Exception; } + public static interface Task { public abstract void perform() throws Exception; } public static void add(Task t) { singleton.runnable.append(t); } - public static void init() { - if (singleton != null) return; - singleton = Platform.getScheduler(); - singleton.run(); + public static void init() { if (singleton == null) (singleton = Platform.getScheduler()).run(); } + + private static Task current = null; + + private static volatile boolean rendering = false; + private static volatile boolean again = false; + + /** 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