Reset the number of crashes of the task.

@param Task $task

@return Task
514414
public function resetCrashes(Task $task)
    {
        $task->setCrashed(0);

        $this->om->persist($task);
        $this->om->flush();

        $this->notify(NotifierInterface::MESSAGE_UPDATE);

        return $task;
    }
984219
public function buildTaskFromClass($task)
    {
        if (is_object($task) && $task instanceof AbstractTask) {
            return $task;
        }

        // Cancel if class doesn't exist
        if (!$class = $this->taskClassExists($task)) {
            throw new TaskCompositionException($task);
        }

        // Build class
        $class = new $class();
        if ($class instanceof ContainerAwareInterface) {
            $class->setContainer($this->container);
        }

        return $class;
    }
99975
protected function fireTasksQueue($tasks)
    {
        $this->prepareEnvironment();

        // Fire tasks and events around them
        $status = $this->runWithBeforeAfterEvents(function () use ($tasks) {
            if ($this->straight) {
                return $this->builder->buildTask($tasks)->fire();
            }

            $pipeline = $this->queue->run($tasks);

            return $pipeline->succeeded();
        });

        // Remove command instance
        $this->container->remove('command');

        // Save history to logs
        $this->explainer->info('Saved logs to '.$this->logs->getLogsRealpath());

        return $status ? 0 : 1;
    }
726553
public function reset()
    {
        foreach ($this->tasks as $task) {
            curl_multi_remove_handle($this->mh, $task['handle']);
        }

        curl_multi_close($this->mh);

        $this->mh = null;
        $this->tasks = [];

        return $this;
    }
780399
protected function composeTask($task)
    {
        // If already built, return it
        if ($task instanceof AbstractTask) {
            return $task;
        }

        // If we passed a callable, build a Closure Task
        if ($this->isCallable($task)) {
            return $this->buildTaskFromCallable($task);
        }

        // If we provided a Closure, build a Closure Task
        if ($task instanceof Closure || $task instanceof SerializableClosure) {
            return $this->buildTaskFromClosure($task);
        }

        // If we passed a task handle, return it
        if ($handle = $this->getTaskHandle($task)) {
            return $this->container->get($handle);
        }

        // If we passed a command, build a Closure Task
        if (is_array($task) || $this->isStringCommand($task) || $task === null) {
            return $this->buildTaskFromString($task);
        }

        // Else it's a class name, get the appropriated task
        if (!$task instanceof AbstractTask) {
            return $this->buildTaskFromClass($task);
        }
    }
567643
public void retry(Task task) {
    if (GobblinMetrics.isEnabled(task.getTaskState().getWorkunit()) &&
        task.getTaskState().contains(ConfigurationKeys.FORK_BRANCHES_KEY)) {
      // Adjust metrics to clean up numbers from the failed task
      task.getTaskState()
          .adjustJobMetricsOnRetry(task.getTaskState().getPropAsInt(ConfigurationKeys.FORK_BRANCHES_KEY));
    }

    // Task retry interval increases linearly with number of retries
    long interval = task.getRetryCount() * this.retryIntervalInSeconds;
    // Schedule the retry of the failed task
    this.taskExecutor.schedule(new TrackingTask(task, interval, TimeUnit.SECONDS), interval, TimeUnit.SECONDS);
    LOG.info(String.format("Scheduled retry of failed task %s to run in %d seconds", task.getTaskId(), interval));
    task.incrementRetryCount();
  }
1170526
protected function runTimedTask(Closure $task)
    {
        $timer = new Stopwatch();
        $timer->start('subtask');

        $task();

        return $timer->stop('subtask')->getDuration();
    }
1233904
public function removeStartTask(\Stackable $task) {
        if ($this->workerStartTasks->contains($task)) {
            $this->workerStartTasks->detach($task);
        }
    }
1206631
public function work($task)
    {
        foreach ($this as $worker) {
            if ($worker->canWork($task)) {
                $workerReport = $worker->work($task);
                if ($workerReport->isSuccessful()) {
                    return $workerReport;
                }
            }
        }

        return $this->getFactory()->createNoAbleWorkersReport();
    }
1150387
protected function _resetTracker($tracker)
    {
        if (!($tracker instanceof Iterator)) {
            throw $this->_createInvalidArgumentException($this->__('Can only reset an Iterator tracker'), null, null, $tracker);
        }

        $tracker->rewind();
    }
1000888
public static function createProcess($task): Runnable
    {
        if (! self::$isInitialised) {
            self::init();
        }

        if (! Pool::isSupported()) {
            return SynchronousProcess::create($task, self::getId());
        }

        $process = new Process(implode(' ', [
            'exec php',
            self::$childProcessScript,
            self::$autoloader,
            self::encodeTask($task),
        ]));

        return ParallelProcess::create($process, self::getId());
    }
1183198
public function updateTask($task): Google_Service_Tasks
    {
        if ($task instanceof Tasks) {
            $task = $task->googleTasks;
        }

        return $this->service->tasks->update($this->tasklist, $task->id, $task);
    }
177933
public function insertTask($task): Google_Service_Tasks
    {
        if ($task instanceof Tasks) {
            $task = $task->googleTasks;
        }

        return $this->service->tasks->insert($this->tasklist, $task);
    }
899357
public function toGruntTask($task)
    {
        $workingDirectory = $this->moodle->directory;
        if (is_file($this->plugin->directory.'/Gruntfile.js')) {
            $workingDirectory = $this->plugin->directory;
        }
        $defaultTask = new GruntTaskModel($task, $workingDirectory);

        switch ($task) {
            case 'amd':
                $amdDir = $this->plugin->directory.'/amd';
                if (!is_dir($amdDir)) {
                    return null;
                }

                return new GruntTaskModel($task, $amdDir, 'amd/build');
            case 'shifter':
            case 'yui':
                $yuiDir = $this->plugin->directory.'/yui';
                if (!is_dir($yuiDir)) {
                    return null;
                }

                return new GruntTaskModel($task, $yuiDir.'/src', 'yui/build');
            case 'gherkinlint':
                if ($this->moodle->getBranch() < 33 || !$this->plugin->hasBehatFeatures()) {
                    return null;
                }

                return new GruntTaskModel($task, $this->moodle->directory);
            case 'stylelint:css':
                return $this->plugin->hasFilesWithName('*.css') ? $defaultTask : null;
            case 'stylelint:less':
                return $this->plugin->hasFilesWithName('*.less') ? $defaultTask : null;
            case 'stylelint:scss':
                return $this->plugin->hasFilesWithName('*.scss') ? $defaultTask : null;
            default:
                return $defaultTask;
        }
    }
147727
public function update(Task $task): Task
    {
        $id = $task->getId();

        $task->setId(null);

        $response = $this->client->put($this->prepareUrlForKey('update-task', ['id' => $id]), [], $task->jsonSerialize());
        $responseData = $response->getDecodedBody();

        return new Task($responseData);
    }
252072
public function endTask(Task $task)
    {
        if ($task->isShallow()) {
            return;
        }

        $endTime = round(microtime(true) * 1000);
        $millis = $endTime - $this->startTime;
        $seconds = floor($millis / 1000);
        $millis = $millis - $seconds * 1000;
        $taskTime = ($seconds > 0 ? "{$seconds}s " : "") . "{$millis}ms";

        $shouldReplaceTaskMark =
            $this->output->isDecorated() &&
            $this->output->getVerbosity() == OutputInterface::VERBOSITY_NORMAL &&
            !$this->output->getWasWritten();

        if ($shouldReplaceTaskMark) {
            $this->output->writeln("\r\033[K\033[1A\r<info>✔</info>");
        } else {
            if ($this->output->getVerbosity() == OutputInterface::VERBOSITY_NORMAL) {
                $this->output->writeln("<info>✔</info> Ok");
            } else {
                $this->output->writeln("<info>✔</info> Ok [$taskTime]");
            }
        }
    }
487335
public function update(Task $task)
    {
        $this->om->persist($task);
        $this->om->flush();

        $this->notify(NotifierInterface::MESSAGE_UPDATE);

        return $task;
    }