Waiting tasks formatter

@param array $tasks
@param bool $plain
@return array
342191
protected function _formatWaiting(array $tasks, $plain) {
		$dependsOnTaskFormatted = array();
		foreach ($tasks as $task) {
			if (!in_array((int)$task['status'], array(TaskType::DEFFERED, TaskType::RUNNING, TaskType::STOPPING, TaskType::UNSTARTED))) {
				continue;
			}
			$dependsOnTaskFormatted[] = $plain ? $task['id'] : $this->id($task);
		}
		return $dependsOnTaskFormatted;
	}
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;
    }
883946
private function getAvailableTasks()
    {
        $tasks = array_map(function ($task) {
            return substr($task, 0, -4);
        }, array_diff(scandir(__DIR__.'/../../Task'), array('.', '..')));

        sort($tasks);

        return $tasks;
    }
731364
public function loadTasks()
    {
        if ($this->tasks === true || empty($this->tasks) || empty($this->Tasks)) {
            return true;
        }
        $this->_taskMap = $this->Tasks->normalizeArray((array)$this->tasks);
        $this->taskNames = array_merge($this->taskNames, array_keys($this->_taskMap));

        $this->_validateTasks();

        return true;
    }
1306326
public static function deliver(
        string $taskName,
        string $methodName,
        array $params = [],
        string $type = self::TYPE_CO,
        int $timeout = 3
    ) {
        if (! in_array($type, [static::TYPE_CO, static::TYPE_ASYNC], false)) {
            throw new TaskException('Invalid task type.');
        }
        $data = TaskHelper::pack($taskName, $methodName, $params, $type);
        if (! App::isWorkerStatus() && ! App::isCoContext()) {
            return static::deliverByQueue($data);
        }

        if (! App::isWorkerStatus() && App::isCoContext()) {
            throw new TaskException('Deliver in non-worker environment, please deliver the task via HTTP request.');
        }

        $server = App::$server->getServer();
        switch ($type) {
            case static::TYPE_CO:
                $tasks[0] = $data;
                $profileKey = 'task' . '.' . $taskName . '.' . $methodName;
                App::profileStart($profileKey);
                $result = $server->taskCo($tasks, $timeout);
                App::profileEnd($profileKey);
                return $result;
                break;
            case static::TYPE_ASYNC:
            default:
                // Deliver async task
                return $server->task($data);
                break;
        }
    }
1005603
public static function find($tasklist, $taskId = null): Tasks
    {
        $service = static::getGoogleTasks($tasklist);

        $googleTasks = $service->getTask($taskId);

        return static::createFromGoogleTasks($googleTasks, $taskId);
    }
430447
private static function createTaskWithCrontabLine($task_class, $matches, $comment)
    {
        $task = $task_class::createNew();
        $task->setTime(trim($matches[2]));
        $arguments = str_replace(' ', ',', trim($matches[5]));
        $command = ucfirst($matches[3]) . '::' . $matches[4] . '(' . $arguments . ')';
        $task->setCommand($command);
        if (!empty($comment)) {
            $task->setComment($comment);
        }
        //$output = $matches[7];
        $status = empty($matches[1]) ? TaskInterface::TASK_STATUS_ACTIVE : TaskInterface::TASK_STATUS_INACTIVE;
        $task->setStatus($status);
        $task->setTs(date('Y-m-d H:i:s'));
        $task->taskSave();
        return $task;
    }
177933
public function insertTask($task): Google_Service_Tasks
    {
        if ($task instanceof Tasks) {
            $task = $task->googleTasks;
        }

        return $this->service->tasks->insert($this->tasklist, $task);
    }
552207
private static function getEmptyResponse($task)
    {
        //====================================================================//
        // Initial Tasks results ArrayObject
        $response = new ArrayObject(array(), ArrayObject::ARRAY_AS_PROPS);

        //====================================================================//
        // Set Default Result to False
        $response->result = false;
        $response->data = null;

        //====================================================================//
        // Insert Task Description Informations
        $response->name = $task->name;
        $response->desc = $task->desc;

        return $response;
    }
989889
function(prepareTiles, rendererHelper,
        visited, flowEvents, sortedRasterizerSlices) {
      if (!prepareTiles.args.prepare_tiles_id)
        return;

      if (!rendererHelper || !rendererHelper.rasterWorkerThreads)
        return;

      var rasterWorkerThreads = rendererHelper.rasterWorkerThreads;
      var prepare_tile_id = prepareTiles.args.prepare_tiles_id;
      var pendingEventQueue = [];

      // Collect all the rasterizer tasks. Return the cached copy if possible.
      if (sortedRasterizerSlices.length === 0)
        this.sortRasterizerSlices(rasterWorkerThreads, sortedRasterizerSlices);

      // TODO(yuhao): Once TaskSetFinishedTaskImpl also get the prepare_tile_id
      // we can simply track by checking id rather than counting.
      var numFinishedTasks = 0;
      var RASTER_TASK_TITLE = 'RasterizerTaskImpl::RunOnWorkerThread';
      var IMAGEDECODE_TASK_TITLE = 'ImageDecodeTaskImpl::RunOnWorkerThread';
      var FINISHED_TASK_TITLE = 'TaskSetFinishedTaskImpl::RunOnWorkerThread';

      for (var i = 0; i < sortedRasterizerSlices.length; i++) {
        var task = sortedRasterizerSlices[i];

        if (task.title === RASTER_TASK_TITLE ||
            task.title === IMAGEDECODE_TASK_TITLE) {
          if (task.args.source_prepare_tiles_id === prepare_tile_id)
            this.addEntireSliceHierarchy(task.mostTopLevelSlice);
        } else if (task.title === FINISHED_TASK_TITLE) {
          if (task.start > prepareTiles.start) {
            pendingEventQueue.push(task.mostTopLevelSlice);
            if (++numFinishedTasks === 3)
              break;
          }
        }
      }

      // Trace PostTask from rasterizer tasks.
      while (pendingEventQueue.length != 0) {
        var event = pendingEventQueue.pop();

        this.addEntireSliceHierarchy(event);
        this.followSubsequentSlices(event, pendingEventQueue, visited,
            flowEvents);
      }
    }
1104349
public function sendBatch($topic, $task, array $messages, array $options = [])
    {
        return array_walk($messages, function ($data) use ($topic, $task, $options) {
            $this->send($topic, $task, $data, $options);
        });
    }
838060
public function pendingTasks()
    {
        $request = $this->createRequestInstance(self::CAT_PENDING_TASKS, null, null);

        return $this->client->send($request);
    }
37900
public function getTasks()
    {
        $tasks = [];

        foreach (get_class_methods($this) as $method) {
            if (preg_match('/Task$/', $method)) {
                $task = new Task($this, $this->getReflection()->getMethod($method));
                $tasks[] = $task;
            }
        }

        return $tasks;
    }
196277
public function tasks($site)
    {
        $variables = array(
            'site' => $site,
        );
        $request = $this->get(array('{+base_path}/sites/{site}/tasks.json', $variables));
        return new Response\Tasks($request);
    }
394978
public function runTask($task, $args = array())
    {
        $wf = $this->getWorkflowObject();
        if (in_array($task, $wf->getAllowedTasks())) {
            $wpr = call_user_func_array(array($wf, $task), array($this, $args));
            $this->updateOnAction($wf);
        }
        if (!($wpr instanceof Response)) {
            $wpr = new Response();
        }

        $event = new GenericEvent();
        $event->setArgument('response', $wpr);

        Events::dispatch('workflow_progressed', $event);

        return $wpr;
    }
1014109
private function _getCreateTaskContext(Task $task)
    {
        $result = new HttpCallContext();
        $result->setMethod(Resources::HTTP_POST);
        $result->setHeaders($this->_batchHeaders);
        $result->setUri($this->getUri());
        $result->setPath('/$1/Tasks');
        $result->setBody($this->wrapAtomEntry($task));
        $result->addStatusCode(Resources::STATUS_CREATED);

        return $result;
    }
450419
public function getTask($task, array $macroOptions = [])
    {
        $script = Arr::get($this->tasks, $task, '');

        if ($script == '') {
            throw new \Exception(sprintf('Task "%s" is not defined.', $task));
        }

        $options = array_merge($this->getTaskOptions($task), $macroOptions);

        $parallel = Arr::get($options, 'parallel', false);

        $confirm = Arr::get($options, 'confirm', null);

        return new Task($this->getServers($options), $options['as'], $script, $parallel, $confirm);
    }