X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Forg%2Fxwt%2FScheduler.java;h=9e939a3d87f7a55c77971268342d403004b4278e;hb=de378041d5ca2aca1a2b5a31ef15ae90a86c977f;hp=cecdee8f9c345828448c5a96517b1b7e661d4665;hpb=2d8e96e82e4c281dd2914fd544b274339fd356d1;p=org.ibex.core.git diff --git a/src/org/xwt/Scheduler.java b/src/org/xwt/Scheduler.java index cecdee8..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(); } + 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