src/hft/scripts/misc/timeout.js
function(elapsedTimeInSeconds) {
    // insert any unscheduled timeouts
    if (s_timeoutsToInsert.length) {
      s_timeoutsToInsert.forEach(insertTimeout);
      s_timeoutsToInsert = [];
    }

    // Now remove any
    if (s_timeoutsToRemoveById.length) {
      s_timeoutsToRemoveById.forEach(removeTimeoutById);
      s_timeoutsToRemoveById = [];
    }

    s_clockInMs += elapsedTimeInSeconds * 1000;

    // process timeouts
    for (var ii = 0; ii < s_timeouts.length; ++ii) {
      var timeout = s_timeouts[ii];
      if (s_clockInMs < timeout.timeToTrigger) {
        break;
      }
      timeout.callback();
    }

    // remove expired timeouts
    s_timeouts.splice(0, ii);
  }
function(elapsedTimeInSeconds) {
    // insert any unscheduled timeouts
    if (s_timeoutsToInsert.length) {
      s_timeoutsToInsert.forEach(insertTimeout);
      s_timeoutsToInsert = [];
    }

    // Now remove any
    if (s_timeoutsToRemoveById.length) {
      s_timeoutsToRemoveById.forEach(removeTimeoutById);
      s_timeoutsToRemoveById = [];
    }

    s_clockInMs += elapsedTimeInSeconds * 1000;

    // process timeouts
    for (var ii = 0; ii < s_timeouts.length; ++ii) {
      var timeout = s_timeouts[ii];
      if (s_clockInMs < timeout.timeToTrigger) {
        break;
      }
      timeout.callback();
    }

    // remove expired timeouts
    s_timeouts.splice(0, ii);
  }
function ( elapsedTimeInSeconds ) { // insert any unscheduled timeouts if ( s_timeoutsToInsert . length ) { s_timeoutsToInsert . forEach ( insertTimeout ) ; s_timeoutsToInsert = [ ] ; } // Now remove any if ( s_timeoutsToRemoveById . length ) { s_timeoutsToRemoveById . forEach ( removeTimeoutById ) ; s_timeoutsToRemoveById = [ ] ; } s_clockInMs += elapsedTimeInSeconds * 1000 ; // process timeouts for ( var ii = 0 ; ii < s_timeouts . length ; ++ ii ) { var timeout = s_timeouts [ ii ] ; if ( s_clockInMs < timeout . timeToTrigger ) { break ; } timeout . callback ( ) ; } // remove expired timeouts s_timeouts . splice ( 0 , ii ) ; }
Processes the intervals and timeouts

This is how you control the clock for the timouts

A typical usage might be


var g = {};
GameSupport.run(g, mainloop);

function mainloop() {
Timeout.process(globals.elapsedTime);
};

@param {number} elapsedTimeInSeconds number of seconds to advance the clock.
@memberOf module:Timeout
Processes the intervals and timeouts