ifdef LeanMode // you can change this function to allow interrupting long calculations from the outside. just throw a RuntimeException. sbool ping() { true; } sbool ping_impl(bool okInCleanUp) { true; } endifdef ifndef LeanMode //sbool ping_actions_shareable = true; static volatile bool ping_pauseAll; static int ping_sleep = 100; // poll pauseAll flag every 100 static volatile bool ping_anyActions; static Map ping_actions = newWeakHashMap(); static new ThreadLocal ping_isCleanUpThread; // always returns true static bool ping() { if (ping_pauseAll || ping_anyActions) ping_impl(true /* XXX */); //ifndef LeanMode ping_impl(); endifndef true; } // returns true when it slept static bool ping_impl(bool okInCleanUp) ctex { if (ping_pauseAll && !isAWTThread()) { do Thread.sleep(ping_sleep); while (ping_pauseAll); true; } if (ping_anyActions) { // don't allow sharing ping_actions if (!okInCleanUp && !isTrue(ping_isCleanUpThread!)) failIfUnlicensed(); O action = null; synchronized(ping_actions) { if (!ping_actions.isEmpty()) { action = ping_actions.get(currentThread()); if (action instanceof Runnable) ping_actions.remove(currentThread()); if (ping_actions.isEmpty()) ping_anyActions = false; } } if (action instanceof Runnable) ((Runnable) action).run(); else if (eq(action, "cancelled")) fail("Thread cancelled."); } ret false; } endifndef