The first part of an iteration that determines how to call the task
429300
function _tick() {
    var config = this._config;
    var now = Date.now();
    var dt = now - this._before;

    if (!this._started) {
      // The ticker has been stopped
      return;
    }

    if (config.async) {
      config.task(this._tock, dt);
    } else {
      config.task(dt);
      this._tock();
    }
  }
738066
private void runSelectTask()
  {
    if (_lifecycle.isActive() || _lifecycle.isAfterStopping()) {
      log.warning(this + " cannot start because an instance is active");
      return;
    }

    initNative(_fd);

    synchronized (_thread) {
      _thread.notify();
    }

    if (! _lifecycle.toActive()) {
      log.warning(this + " invalid starting state");
      return;
    }

    runImpl();
  }
814750
@Override
	public T call() throws Exception {
		logger.debug("task '{}' starting", id);		
		try {
			// do the real work 
			return task.execute();
		} finally {
			// signal that the task is complete
			logger.debug("task '{}' is complete (queue size: {})", id, queue.size());
			queue.offer(id);			
		}
	}
145522
def task_start(self, **kw):
        

        id, task = self.get_task(**kw)

        self._execute(id, 'start')
        return self.get_task(uuid=task['uuid'])[1]
696858
private void setTaskStart() {
        m_taskRecord.setProperty(TaskRecord.PROP_EXECUTOR, m_hostID);
        m_taskRecord.setProperty(TaskRecord.PROP_START_TIME, Long.toString(System.currentTimeMillis()));
        m_taskRecord.setProperty(TaskRecord.PROP_FINISH_TIME, null);
        m_taskRecord.setProperty(TaskRecord.PROP_PROGRESS, null);
        m_taskRecord.setProperty(TaskRecord.PROP_PROGRESS_TIME, null);
        m_taskRecord.setProperty(TaskRecord.PROP_FAIL_REASON, null);
        m_taskRecord.setStatus(TaskStatus.IN_PROGRESS);
        TaskManagerService.instance().updateTaskStatus(m_tenant, m_taskRecord, false);
    }
706865
function(task) {

		if (this._active_tasks.indexOf(task) == -1) {

			this._active_tasks.push(task);

		}

		this._enable();

		if (!this.is_running) {
			this._enable();
			this.is_running = true;
		}

	}
760434
private synchronized void mainLoop() {
        for (Task task: taskDao.listTasks()) {
            if (task.getState().equals(Task.STARTING)) {
                startTask(task);
            } else if (task.getState().equals(Task.PAUSING)) {
                pauseTask(task);
            } else if (task.getState().equals(Task.RESUMING)) {
                resumeTask(task);
            } else if (task.getState().equals(Task.CANCELING)) {
                cancelTask(task);
            }
        }
        try {
            wait(POLL_SECONDS * 1000);
        } catch (InterruptedException e) {
        }
    }
811783
boolean invoke() {
        if (complete) {
            return complete;
        }

        if (iterations >= results.length) {
            int newlen = expandTo(results.length);
            if (newlen < 0) {
                complete = true;
                return complete;
            }
            results = Arrays.copyOf(results, newlen);
        }

        long res = Math.max(task.time(), 1);
        results[iterations] = res;
        if (stable.length > 0) {
            stable[iterations % stable.length] = res;
            if (iterations > stable.length && inBounds(stable, stableLimit)) {
                complete = true;
            }
        }

        remainingTime -= res;
        iterations++;

        if (iterations >= limit || remainingTime < 0) {
            complete = true;
        }
        return complete;
    }
1030388
def start_task(self, task):
        
        self.info("Calculating {}...".format(task))
        self.tasks[task] = self.timer()
456441
def on_task_init(self, task_id, task):
        """"""
        try:
            is_eager = task.request.is_eager
        except AttributeError:
            is_eager = False
        if not is_eager:
            self.close_database()
784458
function() {
      if (this.runCb_ !== undefined)
        this.runCb_.call(this.thisArg_, this);
      var subTasks = this.subTasks_;
      this.subTasks_ = undefined; // Prevent more subTasks from being posted.

      if (!subTasks.length)
        return this.afterTask_;

      // If there are subtasks, then we want to execute all the subtasks and
      // then this task's afterTask. To make this happen, we update the
      // afterTask of all the subtasks so the point upward to each other, e.g.
      // subTask[0].afterTask to subTask[1] and so on. Then, the last subTask's
      // afterTask points at this task's afterTask.
      for (var i = 1; i < subTasks.length; i++)
        subTasks[i - 1].afterTask_ = subTasks[i];
      subTasks[subTasks.length - 1].afterTask_ = this.afterTask_;
      return subTasks[0];
    }
748505
function() {
    firstTaskTimeout = clearTimeout(firstTaskTimeout);
    const task = taskQueue.shift();

    if (task) {
      const conn = idleConnections.shift();
      if (conn) {
        activeConnections[conn.threadId] = conn;
        resetTimeoutToNextTask();
        processTask(conn, task.sql, task.values, task.isBatch)
          .then(task.resolve)
          .catch(task.reject);
      } else {
        taskQueue.unshift(task);
      }
    }
  }
727562
function runQueue() {
		var lastReturned = returned instanceof Array ? returned : [returned]
		  , tasks = queued.shift();

		if (tasks) tasks = tasks.tasks;
		returned = undefined;

		if (tasks instanceof Array) {
			for (var t=0,tt=tasks.length; t<tt; t++) {
				tasks[t].apply(taskObject(t),lastReturned);
			};
			return;
		}
		if (typeof tasks == 'object') {
			for (var t in tasks) if (tasks.hasOwnProperty(t)) {
				tasks[t].apply(taskObject(t),lastReturned);
			}
			return;
		}
	}
91602
private void doStartBatch(String batchID) {
    if (currentBatch != null && currentBatch.id().equals(batchID)) {
      currentBatch.handleStart();
    }
  }
186416
def iterate(self):
        
        self.counter += 1
        self.counter0 += 1
        self.revcounter -= 1
        self.revcounter0 -= 1
        self.first = False
        self.last = (self.revcounter0 == self.len_values - 1)
583985
function () {
        // Grab the first callback in the queue
        var c  = this.q[0],
            fn;

        // If there is no callback in the queue or the Chain is currently
        // in an execution mode, return
        if (!c) {
            this.fireEvent('end');
            return this;
        } else if (this.id) {
            return this;
        }

        fn = c.method || c;

        if (typeof fn === 'function') {
            var o    = c.scope || {},
                args = c.argument || [],
                ms   = c.timeout || 0,
                me   = this;
                
            if (!(args instanceof Array)) {
                args = [args];
            }

            // Execute immediately if the callback timeout is negative.
            if (ms < 0) {
                this.id = ms;
                if (c.until) {
                    for (;!c.until();) {
                        // Execute the callback from scope, with argument
                        fn.apply(o,args);
                    }
                } else if (c.iterations) {
                    for (;c.iterations-- > 0;) {
                        fn.apply(o,args);
                    }
                } else {
                    fn.apply(o,args);
                }
                this.q.shift();
                this.id = 0;
                return this.run();
            } else {
                // If the until condition is set, check if we're done
                if (c.until) {
                    if (c.until()) {
                        // Shift this callback from the queue and execute the next
                        // callback
                        this.q.shift();
                        return this.run();
                    }
                // Otherwise if either iterations is not set or we're
                // executing the last iteration, shift callback from the queue
                } else if (!c.iterations || !--c.iterations) {
                    this.q.shift();
                }

                // Otherwise set to execute after the configured timeout
                this.id = setTimeout(function () {
                    // Execute the callback from scope, with argument
                    fn.apply(o,args);
                    // Check if the Chain was not paused from inside the callback
                    if (me.id) {
                        // Indicate ready to run state
                        me.id = 0;
                        // Start the fun all over again
                        me.run();
                    }
                },ms);
            }
        }

        return this;
    }
840429
void replaceTaskWithResult(int sequence, Object response) {
        int index = toIndex(sequence);
        // If sequence is not equal then it is disposed externally
        if (sequences[index] != sequence) {
            return;
        }
        ringItems[index] = response;
        isTask[index] = false;
        callableCounter--;
    }