Use setTimeout to be invoked only once model
authorJaroslav Tulach <jaroslav.tulach@apidesign.org>
Sun, 07 Apr 2013 17:02:14 +0200
branchmodel
changeset 940350a8fde33da
parent 939 ce08b0b23949
child 941 d1e482f73507
Use setTimeout to be invoked only once
rt/launcher/src/main/java/org/apidesign/bck2brwsr/launcher/impl/Console.java
     1.1 --- a/rt/launcher/src/main/java/org/apidesign/bck2brwsr/launcher/impl/Console.java	Sun Apr 07 16:11:56 2013 +0200
     1.2 +++ b/rt/launcher/src/main/java/org/apidesign/bck2brwsr/launcher/impl/Console.java	Sun Apr 07 17:02:14 2013 +0200
     1.3 @@ -145,7 +145,6 @@
     1.4              try {
     1.5                  if (c == null) {
     1.6                      String data = arr[0];
     1.7 -                    log("\nGot \"" + data + "\"");
     1.8  
     1.9                      if (data == null) {
    1.10                          log("Some error exiting");
    1.11 @@ -161,6 +160,9 @@
    1.12  
    1.13                      c = Case.parseData(data);
    1.14                      beginTest(c);
    1.15 +                    log("Got \"" + data + "\"");
    1.16 +                } else {
    1.17 +                    log("Processing \"" + arr[0] + "\"");
    1.18                  }
    1.19                  Object result = c.runTest();
    1.20                  finishTest(c, result);
    1.21 @@ -169,7 +171,8 @@
    1.22                  new Request(url, u);
    1.23              } catch (Exception ex) {
    1.24                  if (ex instanceof InterruptedException) {
    1.25 -                    interval(this, 100);
    1.26 +                    log("Re-scheduling in 100ms");
    1.27 +                    schedule(this, 100);
    1.28                      return;
    1.29                  }
    1.30                  log(ex.getClass().getName() + ":" + ex.getMessage());
    1.31 @@ -240,8 +243,8 @@
    1.32      }
    1.33  
    1.34      @JavaScriptBody(args = {"r", "time"}, body =
    1.35 -        "return window.setInterval(function() { r.run__V(); }, time);")
    1.36 -    private static native Object interval(Runnable r, int time);
    1.37 +        "return window.setTimeout(function() { r.run__V(); }, time);")
    1.38 +    private static native Object schedule(Runnable r, int time);
    1.39      
    1.40      private static final class Case {
    1.41          private final Object data;