java.lang.Object
org.mozilla.javascript.tools.shell.Timers

public class Timers extends Object
This class supports the "setTimeout" and "clearTimeout" methods of semi-standard JavaScript. It does it within a single thread by keeping track of a queue of timeout objects, and then it blocks the thread. It's used solely within the Shell right now.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    install(org.mozilla.javascript.Scriptable scope)
    Initialize the "setTimeout" and "clearTimeout" functions on the specified scope.
    void
    runAllTimers(org.mozilla.javascript.Context cx, org.mozilla.javascript.Scriptable scope)
    Execute all pending timers and microtasks, blocking the thread if we need to wait for any timers to time out.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Timers

      public Timers()
  • Method Details

    • install

      public void install(org.mozilla.javascript.Scriptable scope)
      Initialize the "setTimeout" and "clearTimeout" functions on the specified scope.
      Parameters:
      scope - the scope where the functions should be defined
    • runAllTimers

      public void runAllTimers(org.mozilla.javascript.Context cx, org.mozilla.javascript.Scriptable scope) throws InterruptedException
      Execute all pending timers and microtasks, blocking the thread if we need to wait for any timers to time out.
      Parameters:
      cx - The Context to use to execute microtasks and timer functions
      scope - the global scope
      Throws:
      InterruptedException - if the thread is interrupted while sleeping