public static long testCont(Sleep ex) throws Exception { System.gc(); try { Thread.sleep(100); } catch (Exception e) { } long start = System.currentTimeMillis(); if (pausable) { // Manually doing what the scheduler would do, just to cut out the // thread scheduling. Fiber f = new Fiber(ex); while (true) { ex.execute(f.begin()); if (f.end()) break; } } else { ex.noPauseRun(); } return (System.currentTimeMillis() - start); }
private void echo(int x) throws Pausable { sleep(); if (pause) { Fiber.pause(); } }
public void execute() throws Pausable { Fiber.pause(); for (int i = 0; i < n; i++) { echo(i); } }