Timeout any windows that have expired in the absence of any events
349638
protected void purgeObsoleteSamples(MetricConfig config, long now) {
        long expireAge = config.samples() * config.timeWindowMs();
        for (int i = 0; i < samples.size(); i++) {
            Sample sample = this.samples.get(i);
            if (now - sample.lastWindowMs >= expireAge) {
                // The samples array is used as a circular list. The rank represents how many spots behind the current
                // window is window #i at. The current sample is rank 0, the next older sample is 1 and so on until
                // the oldest sample, which has a rank equal to samples.size() - 1.
                int rank = current - i;
                if (rank < 0) {
                    rank += samples.size();
                }
                // Here we reset the expired window to a time in the past that is offset proportionally to its rank.
                sample.reset(now - rank * config.timeWindowMs());
            }
        }
    }
1045273
def _reset_timeout(self):
        """"""
        if self._timeout:
            self._timeout.cancel()
        self._timeout = self.loop.call_later(self.client.timeout,
                                             self.transport.close)
127718
function(keys, timeout) {
  this.isDone = false;
  this.keys = keys;
  this.expected = keys.length;
  this.count = 0;
  this.timeout = timeout;
  this.data = {};
  this.errs = [];
  this.events = {
    error: null,
    timeout: null,
    done: null,
  };
  const collector = this;
  if (this.timeout) {
    this.timer = setTimeout(() => {
      const err = new Error(COLLECT_TIMEOUT);
      collector.emit('timeout', err, collector.data);
    }, timeout);
  }
}
346703
def timer_fired(self):
        """"""
        self.__process_idle_events()

        # grab the simulation lock, gather all of the
        # wpilib objects, and display them on the screen
        self.update_widgets()

        # call next timer_fired (or we'll never call timer_fired again!)
        delay = 100  # milliseconds
        self.root.after(delay, self.timer_fired)
285519
private void timeoutExpired(final Timeout timeout, final TimeoutContext context) {
        try {
            removeExpiredTimeout(timeout);

            for (TimeoutExpired callback : callbacks) {
                if (callback instanceof TimeoutExpirationCallback) {
                    ((TimeoutExpirationCallback) callback).expired(timeout, context);
                } else {
                    callback.expired(timeout);
                }
            }
        } catch (Exception ex) {
            // catch all exceptions. otherwise calling timeout thread of timers thread pool will be terminated.
            LOG.error("Error handling timeout.", ex);
        }
    }
551230
def _timeout_expired(self):
        
        self._did_timeout = True
        try:
            self.transport.signalProcess('TERM')
        except error.ProcessExitedAlready:
            # XXX why don't we just always do this?
            self.transport.loseConnection()

        fail = Failure(RuntimeError("timeout while launching Tor"))
        self._maybe_notify_connected(fail)
1164590
def _wait_until_exp(self, timeout, error, function, *args):
		""""""
	
		error = error.replace('<TIMEOUT>', self._format_timeout(timeout))
	
		def wait_func():
			return None if function(*args) else error
			
		self._wait_until_no_error_exp(timeout, wait_func)
1200100
@Override
  public void onTimer(String timerName) {
    if (timerName.equals(IDLE_SESSION_TIMER_NAME)) {
      checkIdleAppSession();
    }
    else if (timerName.equals(TIMER_NAME_TS)) {
      try {
        sendAndStateLock.lock();
        sessionData.setTsTimerId(null);
        handleEvent(new Event(TIMEOUT_EXPIRES, null));
      }
      catch (Exception e) {
        logger.debug("Can not handle event", e);
      }
      finally {
        sendAndStateLock.unlock();
      }
    }
    else {
      logger.warn("Received an unknown timer '{}' for Session-ID '{}'", timerName, getSessionId());
    }
  }
264990
function(){
    // Don't bother if there's no expires token
    if (typeof(service.token.expires_at) === 'undefined' || service.token.expires_at === null) {
      return;
    }
    cancelExpiresAtEvent();
    var time = (new Date(service.token.expires_at))-(new Date());
    if(time && time > 0 && time <= 2147483647){
      expiresAtEvent = $interval(function(){
        $rootScope.$broadcast('oauth:expired', service.token);
      }, time, 1);
    }
  }
565025
public function cmdDeleteEvent()
    {
        if ($this->getParam('expired')) {
            $this->report->deleteExpired();
        } else {
            $this->report->delete();
        }

        $this->output();
    }
501475
def drain_events(self, allowed_methods=None, timeout=None):
        """"""
        return self.wait_multi(self.channels.values(), timeout=timeout)
473258
private void timeout() {
        lock.writeLock().lock();
        try {
            //if already stopped, do nothing, otherwise check times and run the timeout task
            if (!this.stopped) {
                long now = System.nanoTime();
                long remaining = this.targetEnd - now;
                this.timedout = remaining <= FTConstants.MIN_TIMEOUT_NANO;

                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                    debugTime("!Start  {0}", this.start);
                    debugTime("!Target {0}", this.targetEnd);
                    debugTime("!Now    {0}", now);
                    debugTime("!Remain {0}", remaining);
                }

                //if we really have timedout then run the timeout task
                if (this.timedout) {
                    debugRelativeTime("Timeout!");
                    this.timeoutTask.run();
                } else {
                    //this shouldn't be possible but if the timer popped too early, restart it
                    debugTime("Premature Timeout!", remaining);
                    start(this.timeoutTask, remaining);
                }
            }
        } finally {
            lock.writeLock().unlock();
        }
    }
119541
def cleanup(self, timeout):
        '''
        
        '''
        cutoff = time() - timeout
        self.collection.remove({_atime: {'$lt': cutoff}})
664901
function(callback) {
			var timeout = window.setTimeout(function(){
				callback();
			},2000);
			window.onload = function(){
				clearTimeout(timeout);
				callback();
			};
		}
280750
protected function removeLastEventIfOutsideWindowAndNonRecurring()
    {
        $events = $this->cal['VEVENT'];

        if (!empty($events)) {
            $lastIndex = sizeof($events) - 1;
            $lastEvent = $events[$lastIndex];

            if (!isset($lastEvent['RRULE']) || $lastEvent['RRULE'] === '' && $this->doesEventStartOutsideWindow($lastEvent)) {
                $this->eventCount--;

                unset($events[$lastIndex]);
            }

            $this->cal['VEVENT'] = $events;
        }
    }
1028237
def wait(self, timeout=None):
        """"""
        self._event.wait(timeout)
        return self._event.isSet()
454278
protected void deleteCleanupTimer(W window) {
		long cleanupTime = cleanupTime(window);
		if (cleanupTime == Long.MAX_VALUE) {
			// no need to clean up because we didn't set one
			return;
		}
		if (windowAssigner.isEventTime()) {
			triggerContext.deleteEventTimeTimer(cleanupTime);
		} else {
			triggerContext.deleteProcessingTimeTimer(cleanupTime);
		}
	}