To be used in conjunction with the above function for checking if the timer has run out.
972367
public function timerUp() {
		if(!self::get('timer') || !self::get('timeout')) return false;
		return (time() - self::get('timeout') >= self::get('timer')) ? true : false;
	}
683821
def _finish(self):
        
        if self.active and self.cnt >= self.max_iter:
            self.total_time = self._elapsed()
            self.end = time.time()
            self.last_progress -= 1  # to force a refreshed _print()
            self._print()
            if self.track:
                self._stream_out('\nTotal time elapsed: ' +
                                 self._get_time(self.total_time))
            self._stream_out('\n')
            self.active = False
1219656
def _is_timeout(self):
        '''  '''
        if self.cputime is None:
            is_cpulimit = False
        else:
            rlimits = self.runSet.benchmark.rlimits
            if SOFTTIMELIMIT in rlimits:
                limit = rlimits[SOFTTIMELIMIT]
            elif TIMELIMIT in rlimits:
                limit = rlimits[TIMELIMIT]
            else:
                limit = float('inf')
            is_cpulimit = self.cputime > limit

        if self.walltime is None:
            is_walllimit = False
        else:
            rlimits = self.runSet.benchmark.rlimits
            if WALLTIMELIMIT in rlimits:
                limit = rlimits[WALLTIMELIMIT]
            else:
                limit = float('inf')
            is_walllimit = self.walltime > limit

        return is_cpulimit or is_walllimit
361585
def end_timing(self, name, elapsed):
        
        counter = self.get(name, CounterType.Interval)
        self._calculate_stats(counter, elapsed)
        self._update()
953851
def run_time_or_time_elapsed
      if self.end_time         
         return Time.at(self.end_time - self.start_time)
      else
         return Time.at(Time.now - self.start_time)
      end
    end
1233536
Optional<String> writeFunctionTimer(FunctionTimer timer) {
        return Optional.of(writeDocument(timer, builder -> {
            builder.append(",\"count\":").append(timer.count());
            builder.append(",\"sum\" :").append(timer.totalTime(getBaseTimeUnit()));
            builder.append(",\"mean\":").append(timer.mean(getBaseTimeUnit()));
        }));
    }
873442
def _check(self):
        ''''''
        _logger.debug('Check if timeout.')
        self._call_later_handle = None

        if self._touch_time is not None:
            difference = self._event_loop.time() - self._touch_time
            _logger.debug('Time difference %s', difference)

            if difference > self._timeout:
                self._connection.close()
                self._timed_out = True

        if not self._connection.closed():
            self._schedule()
894494
def check(self):
        
        try:
            self.join(timeout=0)
        except Exception as e:
            logger.exception(e)
            raise
1314835
protected void checkTimeouts() {

		// Compute timeout limits
		long now = System.currentTimeMillis();
		Iterator<NodeDescriptor> i;
		NodeDescriptor node;

		// Check offline timeout
		if (offlineTimeout > 0) {
			i = nodes.values().iterator();
			long offlineTimeoutMillis = offlineTimeout * 1000L;
			while (i.hasNext()) {
				node = i.next();
				if (node.local) {
					continue;
				}
				node.readLock.lock();
				try {
					if (node.offlineSince > 0 && now - node.offlineSince > offlineTimeoutMillis) {

						// Remove node info from registry
						i.remove();
						logger.info("Node \"" + node.nodeID + "\" is no longer registered because it was inactive for "
								+ offlineTimeout + " seconds.");

					}
				} finally {
					node.readLock.unlock();
				}
			}
		}

		// Check heartbeat timeout
		if (heartbeatTimeout > 0) {
			long heartbeatTimeoutMillis = heartbeatTimeout * 1000L;
			i = nodes.values().iterator();
			LinkedList<NodeDescriptor> disconnectedNodes = new LinkedList<>();
			while (i.hasNext()) {
				node = i.next();
				if (node.local) {
					continue;
				}
				node.writeLock.lock();
				try {
					if (node.cpuWhen > 0 && now - node.cpuWhen > heartbeatTimeoutMillis && node.markAsOffline()) {

						// Remove services and listeners
						registry.removeActions(node.nodeID);
						eventbus.removeListeners(node.nodeID);
						disconnectedNodes.add(node);
					}
				} finally {
					node.writeLock.unlock();
				}
			}
			i = disconnectedNodes.iterator();
			while (i.hasNext()) {
				node = i.next();

				// Notify listeners
				logger.info("Heartbeat is not received from \"" + node.nodeID + "\" node.");
				logger.info("Node \"" + node.nodeID + "\" disconnected unexpectedly.");
				broadcastNodeDisconnected(node.info, true);
			}
		}
	}
855944
function Timer(timer, clear, fn) {
      this.clear = clear;
      this.timer = timer;
      this.fns = [fn];
    }
765660
public static void endTimer(Optional<Timer.Context> timer) {
    timer.transform(new Function<Timer.Context, Timer.Context>() {
      @Override
      public Timer.Context apply(@Nonnull Timer.Context input) {
        input.close();
        return input;
      }
    });
  }
18924
function monitor(interval, timeoutCb, pingTimeout) {
  pingTimeout = pingTimeout || interval;
  let currentTimeout;
  let currentInterval;
  let closed = false;

  const onTimeoutExpired = () => {
    if (closed) return;
    closed = true;

    clearTimeout(currentTimeout);
    clearInterval(currentInterval);
    timeoutCb();
  };


  const ping = () => {
    this.ping(undefined, undefined, true);

    if (currentTimeout) return;
    currentTimeout = setTimeout(onTimeoutExpired, pingTimeout);
  };

  this.on('pong', () => {
    clearTimeout(currentTimeout);
    currentTimeout = undefined;
  });

  this.on('close', () => onTimeoutExpired());
  this.on('error', () => onTimeoutExpired());
  currentInterval = setInterval(() => ping(), interval);
}
483899
function () {
      var i;
      for (i = 0; i < arguments.length; i++) {
         if ( ! (this.has_activity_completed(arguments[i]) || this.has_lambda_completed(arguments[i]) || this.childworkflow_completed(arguments[i])  || this.timer_fired(arguments[i]) ) ) {
            return false;
         }
      }
      return true;
   }
1271438
def _shutdown_timer(self) -> None:
        
        remaining = self._max_run_time - self.uptime
        if not self.shutdown_pending.wait(remaining):
            logger.warning('Run time reached zero')
            self.shutdown()
254031
def _monitor(last_ping, stop_plugin, is_shutting_down, timeout=5):
    
    _timeout_count = 0
    _last_check = time.time()
    _sleep_interval = 1
    # set _sleep_interval if less than the timeout
    if timeout < _sleep_interval:
        _sleep_interval = timeout
    while True:
        time.sleep(_sleep_interval)
        # Signals that stop_plugin has been called
        if is_shutting_down():
            return
        # have we missed a ping during the last timeout duration
        if ((time.time() - _last_check) > timeout) and ((time.time() - last_ping()) > timeout):
            # reset last_check
            _last_check = time.time()
            _timeout_count += 1
            LOG.warning("Missed ping health check from the framework. " +
                        "({} of 3)".format(_timeout_count))
            if _timeout_count >= 3:
                stop_plugin()
                return
        elif (time.time() - last_ping()) <= timeout:
            _timeout_count = 0
935206
function() {
            if (self._disposed) {
                clearTimeout(timeout)
                timeout = self = null
                return
            }

            var last = getTime() - timestamp

            if (last < wait && last >= 0) {
                timeout = setTimeout(later, wait - last)
            } else {
                timeout = null
                // result = func.apply(context, args)
                func()
                // context = args = null
            }
        }
8012
function t(time, done) {
  if (arguments.length === 1) {
    done = time;
    time = 2000;
  }
  var error = new Error(`Callback took too long (max: ${time})`);
  var waiting = true;

  var timeout = setTimeout(function () {
    if (!waiting) return;
    waiting = false;
    done(error);
  }, time);

  function handler() {
    if (!waiting) return;
    clearTimeout(timeout);
    waiting = false;
    done.apply(this, arguments);
  }

  return handler;
}