X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;ds=sidebyside;f=src%2Forg%2Fibex%2Fplat%2FPlatform.java;h=389caa4f03c975258b0cd6e543301c1e63b8e549;hb=890000a10a0ccdc49f62946bddf1c0b840495a94;hp=857a8778de03e2c38966b5683becf1c71aed781a;hpb=0db31fc0dc88749cd8022790fd475df8b7b06c27;p=org.ibex.core.git diff --git a/src/org/ibex/plat/Platform.java b/src/org/ibex/plat/Platform.java index 857a877..389caa4 100644 --- a/src/org/ibex/plat/Platform.java +++ b/src/org/ibex/plat/Platform.java @@ -51,7 +51,7 @@ public abstract class Platform { String os_name = System.getProperty("os.name", ""); String os_version = System.getProperty("os.version", ""); String platform_class = null; - + if (vendor.startsWith("Free Software Foundation")) { if (os_name.startsWith("Window")) platform_class = "Win32"; else if (os_name.startsWith("Linux")) platform_class = "Linux"; @@ -60,8 +60,8 @@ public abstract class Platform { else if (os_name.startsWith("Darwin")) platform_class = "Darwin"; else platform_class = "X11"; } + else if (version.startsWith("1.4")) platform_class = "Java4"; else if (!version.startsWith("1.0") && !version.startsWith("1.1")) platform_class = "Java2"; - if (platform_class == null) { Log.error(Platform.class, "Unable to detect JVM"); criticalAbort("Unable to detect JVM"); @@ -118,7 +118,7 @@ public abstract class Platform { ret.setInvisible(false); if (refreshable) { Surface.allSurfaces.addElement(ret); - ret.dirty(0, 0, b.width, b.height); + b.dirty(); ret.Refresh(); } try { @@ -293,6 +293,91 @@ public abstract class Platform { return p; } } + + /** Implements cooperative multitasking */ + public static class Scheduler { + + // Public API Exposed to org.ibex ///////////////////////////////////////////////// + + private static Scheduler singleton; + public static void add(Callable t) { Log.debug(Scheduler.class, "scheduling " + t); Scheduler.runnable.append(t); } + public static void init() { if (singleton == null) (singleton = Platform.getScheduler()).run(); } + + private static Callable 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