This makes checks on queue, moves it to proper state if event there is
present on Open state ;]
766080
protected void dispatch() {
    // Event Based ----------------------------------------------------------
    if (isEventBased()) {
      // Current State: IDLE
      // Event: Request in storage
      // Action: Send stored request
      // New State: PENDING_B
      Request buffer = this.sessionData.getBuffer();
      if (buffer != null) {
        setState(ClientCCASessionState.PENDING_BUFFERED);
        try {
          dispatchEvent(new AppRequestEventImpl(buffer));
        }
        catch (Exception e) {
          try {
            handleSendFailure(e, Event.Type.SEND_EVENT_REQUEST, buffer);
          }
          catch (Exception e1) {
            logger.error("Failure handling buffer send failure", e1);
          }
        }
      }
    }
    // Session Based --------------------------------------------------------
    else {
      if (this.sessionData.getClientCCASessionState() == ClientCCASessionState.OPEN && eventQueue.size() > 0) {
        try {
          this.handleEvent(eventQueue.remove(0));
        }
        catch (Exception e) {
          logger.error("Failure handling queued event", e);
        }
      }
    }
  }
744639
def queue_actions(self, source, actions, event_args=None):
		
		source.event_args = event_args
		ret = self.trigger_actions(source, actions)
		source.event_args = None
		return ret
71246
function _go() {
        if(workers < concurrency) {
            var job = queue.shift();
            if(job !== undefined) {
                var worker = job.shift();
                job.push(over);
                workers++;
                process.nextTick(function nextTickWorker() {
                    worker.apply(null, job);
                });
                return true;
            }
        }
        return false;
    }
682419
private void jobStateChanged(JobStatusChangeEvent event, QueueInfo qi) {
    JobInProgress job = event.getJobInProgress();
    JobSchedulingInfo oldJobStateInfo = 
      new JobSchedulingInfo(event.getOldStatus());
    // Check if the ordering of the job has changed
    // For now priority and start-time can change the job ordering
    if (event.getEventType() == EventType.PRIORITY_CHANGED 
        || event.getEventType() == EventType.START_TIME_CHANGED) {
      // Make a priority change
      reorderJobs(job, oldJobStateInfo, qi);
    } else if (event.getEventType() == EventType.RUN_STATE_CHANGED) {
      // Check if the job is complete
      int runState = job.getStatus().getRunState();
      if (runState == JobStatus.SUCCEEDED
          || runState == JobStatus.FAILED
          || runState == JobStatus.KILLED) {
        jobCompleted(job, oldJobStateInfo, qi);
      } else if (runState == JobStatus.RUNNING) {
        makeJobRunning(job, oldJobStateInfo, qi);
      }
    }
  }
1256719
def handle_in_source_state
      if @state_machine.initial_queue.nil?
        raise RuntimeError, "State machine not started yet."
      end

      if Dispatch::Queue.current.to_s != @state_machine.initial_queue.to_s
        raise RuntimeError,
          "#{self.class.event_type}:#{@event_trigger_value} must be "\
          "called from the queue where the state machine was started."
      end

      @source_state.send :guarded_execute,
        self.class.event_type,
        @event_trigger_value
    end
320148
function check() {
    if (links[currentLink] && currentLink < upTo) {
        this.echo('--- Link ' + currentLink + ' ---');
        start.call(this, links[currentLink]);
        addLinks.call(this, links[currentLink]);
        currentLink++;
        this.run(check);
    } else {
        this.echo("All done.");
        this.exit();
    }
}
180589
private void checkStatePlaying()
    {
        if (!reverse)
        {
            if (repeat)
            {
                state = AnimState.PLAYING;
                current = first;
            }
            else
            {
                state = AnimState.FINISHED;
            }
        }
        else
        {
            state = AnimState.REVERSING;
        }
    }
672630
def run_checked (self):
        """"""
        self.start_time = time.time()
        self.setName("Interrupt")
        while not self.stopped(self.WaitSeconds):
            duration = time.time() - self.start_time
            if duration > self.duration:
                log.warn(LOG_CHECK, "Interrupt after %s" % strformat.strduration_long(duration))
                raise KeyboardInterrupt()
571827
function onStateChanged(opts, that) {
        var eventProcessor = {
          resize: function resize(that) {
            if (opts && opts.onResize) {
              opts.onResize.call(that, that);
            } else if (this.onResize) {
              this.onResize.call(that, that);
            }
          },
          move: function move() {}
        };
        if (that.state in eventProcessor) {
          eventProcessor[that.state].call(this, that);
        }

        if (opts && opts.onStateChanged) {
          opts.onStateChanged.call(that, that);
        } else if (this.onStateChanged) {
          this.onStateChanged.call(that, that);
        }
        return true;
      }
969724
function processServeQueue() {
      while (serveQueue.length) {
        const item = serveQueue.shift();
        _serveFile(item.file, item.done);
        // It is possible start compiling while in release.
        if (state.compilationCompleted !== _currentState) {
          break;
        }
      }
    }
1324827
function checkQueue() {
    if(!inInterval()) {
      if(requestQueue.length) {
        var next = requestQueue.shift();
        sendRequest(next);
      } else if(timer) {
        clearInterval(timer); // No need to leave the timer running if we don't have any requests.
      }
    }
  }
1301744
def on_event(self, event):
        ''''''
        state = self.state
        if isinstance(event, wx.MouseEvent):
            self.on_mouse_event(event)
        if isinstance(event, wx.KeyEvent):
            self.on_key_event(event)
        if (isinstance(event, wx.MouseEvent) and
            not event.ButtonIsDown(wx.MOUSE_BTN_ANY) and
            event.GetWheelRotation() == 0):
            # don't flood the queue with mouse movement
            return
        evt = mp_util.object_container(event)
        pt = self.image_coordinates(wx.Point(evt.X,evt.Y))
        evt.X = pt.x
        evt.Y = pt.y
        state.out_queue.put(evt)
1132713
protected function checkIfAllReady()
    {
        $this->checkQueue();
        if ($this->resultsNum >= $this->jobsNum) {
            $this->jobs = [];
            $this->state = self::STATE_DONE;
            foreach ($this->listeners as $cb) {
                $cb($this);
            }
            if (!$this->keep && $this->resultsNum >= $this->jobsNum) {
                $this->cleanup();
            }
        }
    }
499939
def __process_idle_events(self):
        """"""
        while True:
            try:
                callable, args = self.queue.get(block=False)
            except queue.Empty:
                break
            callable(*args)
1182275
protected void done() {
        try {
            page.getEventQueue().queue(event);
        } catch (Exception e) {
            log.error(e);
        }
    }
1110439
def _check_events(tk):
    """"""

    used = False
    try:
        # Process all enqueued events, then exit.
        while True:
            try:
                # Get an event request from the queue.
                method, args, kwargs, response_queue = tk.tk._event_queue.get_nowait()
            except queue.Empty:
                # No more events to process.
                break
            else:
                # Call the event with the given arguments, and then return
                # the result back to the caller via the response queue.
                used = True
                if tk.tk._debug >= 2:
                    print('Calling event from main thread:', method.__name__, args, kwargs)
                try:
                    response_queue.put((False, method(*args, **kwargs)))
                except SystemExit:
                    raise  # Raises original SystemExit
                except Exception:
                    # Calling the event caused an exception; return the
                    # exception back to the caller so that it can be raised
                    # in the caller's thread.
                    from sys import exc_info  # Python 2 requirement
                    ex_type, ex_value, ex_tb = exc_info()
                    response_queue.put((True, (ex_type, ex_value, ex_tb)))
    finally:
        # Schedule to check again. If we just processed an event, check
        # immediately; if we didn't, check later.
        if used:
            tk.after_idle(_check_events, tk)
        else:
            tk.after(tk.tk._check_period, _check_events, tk)
990552
public void updateState() {
        if (Thread.currentThread() == this.homeThread) {
            IState state = null;
            // Check the state queue to see if we need to carry out a transition:
            synchronized (this.stateQueue) {
                if (this.stateQueue.size() > 0) {
                    state = this.stateQueue.remove(0);
                }
            }
            if (state != null) {
                setState(state);   // Transition to the next state.
            }
        }
    }