private static Task current = null;
public static Task current() { return current; }
+ /** synchronizd so that we can safely call it from an event-delivery thread, in-context */
+ public static synchronized void renderAll() {
+ for(int i=0; i<Surface.allSurfaces.size(); i++) {
+ Surface s = ((Surface)Surface.allSurfaces.elementAt(i));
+ do { s.render(); } while(s.abort);
+ }
+ }
+
+
+
// API which must be supported by subclasses /////////////////////////////////////
/**
while(true) {
current = (Task)runnable.remove(true);
try {
- for(int i=0; i<Surface.allSurfaces.size(); i++) {
- Surface s = (Surface)Surface.allSurfaces.elementAt(i);
- if (current instanceof JSFunction) {
- s._mousex = Integer.MAX_VALUE;
- s._mousey = Integer.MAX_VALUE;
- } else {
- s._mousex = s.mousex;
- s._mousey = s.mousey;
+ synchronized(this) {
+ for(int i=0; i<Surface.allSurfaces.size(); i++) {
+ Surface s = (Surface)Surface.allSurfaces.elementAt(i);
+ if (current instanceof JSFunction) {
+ s._mousex = Integer.MAX_VALUE;
+ s._mousey = Integer.MAX_VALUE;
+ } else {
+ s._mousex = s.mousex;
+ s._mousey = s.mousey;
+ }
}
+ current.perform();
}
- current.perform();
- if (runnable.size() == 0 && Surface.needRender) Surface.renderAll.perform();
+ renderAll();
} catch (JSExn e) {
- Log.log(Scheduler.class, "a JavaScript thread spawned with xwt.thread() threw an exception:");
- Log.log(Scheduler.class, e);
+ Log.info(Scheduler.class, "a JavaScript thread spawned with xwt.thread() threw an exception:");
+ Log.info(Scheduler.class, e);
} catch (Exception e) {
- Log.log(Scheduler.class, "a Task threw an exception which was caught by the scheduler:");
- Log.log(Scheduler.class, e);
+ Log.info(Scheduler.class, "a Task threw an exception which was caught by the scheduler:");
+ Log.info(Scheduler.class, e);
}
// if an Error is thrown it will cause the engine to quit
}