Fired after every event, decide if we want to stop waiting
11206
function ontick(next) {
      // No point in waiting that long
      if (next >= timeoutOn) {
        timeout();
        return;
      }

      const activeWindow = eventLoop.active;
      if (completionFunction && activeWindow.document.documentElement)
        try {
          const waitFor   = Math.max(next - Date.now(), 0);
          // Event processed, are we ready to complete?
          const completed = completionFunction(activeWindow, waitFor);
          if (completed)
            done();
        } catch (error) {
          done(error);
        }

    }
1232263
def stop(self):
        """"""
        if not self._dead:
            self._killed = True
            self._cancelled.set()
            self._busy_sem.release()
            self.join()
            if not self._ready_sem.acquire(False):
                warning("ISOTP Timer thread may not have stopped "
                        "correctly")
35100
async def wait_for_send(self, event, *, until=None):
        '''
        
        '''
        while True:
            if until:
                r = until()
                if r:
                    return r
            waiter = self.scheduler.send(event)
            if waiter is None:
                break
            await waiter
557391
function waitForReadyState(element, readyState, interval, done) {
  var timer = setInterval(function() {
    if (element.readyState >= readyState) {
      clearInterval(timer);
      done(null, true);
    }
  }, interval);
}
293412
function stop () {
        currentValues = fromValues;
        triggerEvent('stop');
        stopLoop(animationId);
        pausedAfter = undefined;
        startTime = undefined;
        return self;
      }
1299921
function later (info) {
	process.stdin.resume();
	const action = start.bind(null, info);
	process.on('SIGINT', action);
	process.on('SIGTERM', action);

	(function wait () {
		if (beenthere) {
			return;
		}

		setTimeout(wait, EVENT_LOOP);
	}());
}
194135
def _trigger(self):
        
        self._completed.set()
        for callback in self._callbacks:
            callback(self)
265473
def wait_for_event(event):
    
    f = Future()
    def ready():
        get_event_loop().remove_win32_handle(event)
        f.set_result(None)
    get_event_loop().add_win32_handle(event, ready)
    return f
145859
public void waitUntilFinish() {
        while (!finished) {
            synchronized (waitingLock) {
                if (config.isHaltOnError()) {
                    Throwable t = getError();
                    if (t != null && config.isHaltOnError()) {
                        if (t instanceof RuntimeException) {
                            throw (RuntimeException)t;
                        } else if (t instanceof Error) {
                            throw (Error)t;
                        } else {
                            throw new RuntimeException("error on monitor thread", t);
                        }
                    }
                }
                if (finished) {
                    return;
                }
                try {
                    waitingLock.wait();
                } catch (InterruptedException e) {
                    logger.error("Error occurred", e);
                }
            }
        }
    }
356285
def wait_until_finished(self):
        """"""
        try:
            self.thread.join()
        except KeyboardInterrupt:
            self._logger.debug('Keyboard interrupt detected, stopping driver.')
            self._active = False
            self._wake_queue()
1139639
def trigger_events(events, loop):
    
    for event in events:
        result = event(loop)
        if isawaitable(result):
            loop.run_until_complete(result)
168612
def terminate_all(wait=False):
        
        for instance in Process.instances:
            if instance.is_running():
                instance.terminate(wait)
700157
def on_any_event(self, event):
        """"""
        if os.path.isfile(event.src_path):
            self.callback(event.src_path, **self.kwargs)
1320572
function done() {
        var arg = errors.length ? errors : null
        --pending || process.nextTick(callback, arg)
    }
812641
def should_stop(self, result):
        """"""

        if result.get(DONE):
            return True

        for criteria, stop_value in self.stopping_criterion.items():
            if criteria not in result:
                raise TuneError(
                    "Stopping criteria {} not provided in result {}.".format(
                        criteria, result))
            if result[criteria] >= stop_value:
                return True

        return False
354162
def on_success(&block)
      on do |_, value, reason|
        block.call(value) unless reason
      end
    end
358393
def on_pause(self):
        """"""
        self.engine.commit()
        self.strings.save()
        self.funcs.save()
        self.config.write()