X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;ds=sidebyside;f=src%2Forg%2Fibex%2Fplat%2FPlatform.java;h=e3e68e6a6addaa652f66335024a699a360204bbd;hb=HEAD;hp=f0161ee0bc6c8636cc7fafbf878b94d0b9c54176;hpb=73fffe7949d37db1983329ed03c4119702064c54;p=org.ibex.core.git diff --git a/src/org/ibex/plat/Platform.java b/src/org/ibex/plat/Platform.java index f0161ee..e3e68e6 100644 --- a/src/org/ibex/plat/Platform.java +++ b/src/org/ibex/plat/Platform.java @@ -11,7 +11,7 @@ import org.ibex.js.*; import org.ibex.util.*; import org.ibex.graphics.*; import org.ibex.core.*; -import org.ibex.graphics.*; +import org.ibex.crypto.*; import org.ibex.core.*; import org.ibex.net.*; @@ -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"; @@ -260,6 +260,8 @@ public abstract class Platform { if (alreadyDetectedProxy) return null; alreadyDetectedProxy = true; + // FIXME + /* Log.info(Platform.class, "attempting environment-variable DNS proxy detection"); cachedProxyInfo = org.ibex.net.HTTP.Proxy.detectProxyViaManual(); if (cachedProxyInfo != null) return cachedProxyInfo; @@ -267,7 +269,7 @@ public abstract class Platform { Log.info(Platform.class, "attempting " + platform.getClass().getName() + " proxy detection"); cachedProxyInfo = platform._detectProxy(); if (cachedProxyInfo != null) return cachedProxyInfo; - + */ return cachedProxyInfo; } @@ -293,6 +295,141 @@ 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