示例#1
0
  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);
  }
示例#2
0
 private void echo(int x) throws Pausable {
   sleep();
   if (pause) {
     Fiber.pause();
   }
 }
示例#3
0
 public void execute() throws Pausable {
   Fiber.pause();
   for (int i = 0; i < n; i++) {
     echo(i);
   }
 }