@param WorkerInterface $worker

@return bool
516030
public static function isProcessEventGenerator(WorkerInterface $worker) : bool
    {
        try{
            $method = new \ReflectionMethod($worker, 'processEvent');

            return $method->isGenerator();
        }
        catch(\ReflectionException $e)
        {
            return false;
        }
    }
780202
public function sendRequest(Worker $worker, Request $request)
    {
        $worker->setRequest($request);
        $this->reply(
            $worker,
            new ExecuteJobRequest(
                $request->getId(),
                $request->getActionName(),
                $request->getParams()
            )
        );
    }
1240008
public function startWorker(WorkerInterface $worker)
    {
        $parent = $this->system->createCurrentProcess();

        $this->eventDispatcher->dispatch(ResqueEvents::PRE_FORK);

        $child = $parent->fork();

        // This exists because workers that get reset after a crash still hold their old id.
        // @todo this shouldn't be needed if id was always derived.. hmm.
        $worker->setId(null);

        if (null === $child) {
            // This is spawned worker process, it will process jobs until told to exit.
            $this->eventDispatcher->dispatch(ResqueEvents::POST_FORK_CHILD);

            $worker->setProcess($this->system->createCurrentProcess());

            $this->registry->register($worker);
            $worker->work();
            $this->registry->deregister($worker);

            exit(0);
        }

        $this->eventDispatcher->dispatch(ResqueEvents::POST_FORK_PARENT);

        $worker->setProcess($child);

        $this->logger->info(
            'Successfully started worker {worker} with pid {childPid}',
            array(
                'worker' => $worker,
                'childPid' => $child->getPid(),
            )
        );
    }
203087
public function worker($worker) : EventLoop
    {
        if (is_callable($worker) || $worker instanceof WorkerInterface){
            $this->workers[] = $worker;
        }
        return $this;
    }
1254769
protected static function forkOneWorkerForLinux($worker)
    {
        // Get available worker id.
        $id = static::getId($worker->workerId, 0);
        if ($id === false) {
            return;
        }
        $pid = pcntl_fork();
        // For master process.
        if ($pid > 0) {
            static::$_pidMap[$worker->workerId][$pid] = $pid;
            static::$_idMap[$worker->workerId][$id]   = $pid;
        } // For child processes.
        elseif (0 === $pid) {
            srand();
            mt_srand();
            if ($worker->reusePort) {
                $worker->listen();
            }
            if (static::$_status === static::STATUS_STARTING) {
                static::resetStd();
            }
            static::$_pidMap  = array();
            // Remove other listener.
            foreach(static::$_workers as $key => $one_worker) {
                if ($one_worker->workerId !== $worker->workerId) {
                    $one_worker->unlisten();
                    unset(static::$_workers[$key]);
                }
            }
            Timer::delAll();
            static::setProcessTitle('WorkerMan: worker process  ' . $worker->name . ' ' . $worker->getSocketName());
            $worker->setUserAndGroup();
            $worker->id = $id;
            $worker->run();
            $err = new Exception('event-loop exited');
            static::log($err);
            exit(250);
        } else {
            throw new Exception("forkOneWorker fail");
        }
    }
941479
private function scheduleTask(TaskInterface $task, array $workload)
    {
        return $this->taskScheduler->createTask($task->getHandlerClass(), $workload)
            ->executeAt($task->getSchedule())
            ->schedule();
    }
1372856
private function checkCreation(TokenInterface $token)
    {
        if ($this->hasAdminToolAccess($token, 'workspace_management') || $this->isWorkspaceCreator($token)) {
            return VoterInterface::ACCESS_GRANTED;
        }

        return VoterInterface::ACCESS_DENIED;
    }
1163243
public function addWorker(Worker $worker, $priority = 0)
    {
        $this->workers->attach($worker, $priority);
        return $this;
    }
896576
public static function hasInterface($objectOrClass, string $interfaceClassName): bool
    {
        return in_array($interfaceClassName, self::getInterfaces($objectOrClass));
    }
1041035
public function redirectIt(EventInterface $event)/*# : bool */
    {
        /* @var ResultInterface $result */
        $result = $event->getParam('result');

        if (!isset($_SERVER['HTTPS'])) {
            $result->setStatus(Status::MOVED_PERMANENTLY);
            return false;
        }
        return true;
    }
344545
public function verify(TokenInterface $token): bool
    {
        $signer = $this->factory->create($token->algorithm());
        $key    = new Key($this->verifyKey->content(), $this->verifyKey->passphrase());

        return $signer->verify($token->signature(), $token->payload(), $key);
    }
1021036
public function get(CacheableInterface $item)
    {
        return isset($this->values[$item->getHashKey()]) ? $this->values[$item->getHashKey()] : false;
    }
1092327
protected function execute(InputInterface $input, OutputInterface $output)
    {
        if ($this->option('worker')) {
            return $this->worker();
        }

        if ($this->option('cron')) {
            return $this->cron();
        }

        if ($this->option('heartbeat')) {
            return $this->heartbeat();
        }

        return parent::execute($input, $output);
    }
952253
public function add(Worker $worker, AbstractThread $thread)
    {
        $this->threads[$thread->getId()] = $worker->getId();
        $this->workers[$worker->getId()][$thread->getId()] = $thread;
    }
1076567
public function perform(JobInterface $job)
    {
        $status = sprintf('Performing job %s:%s', $job->getOriginQueue(), $job->getId());
        $this->getProcess()->setTitle($status);
        $this->getLogger()->info($status);

        if ($job instanceof TrackableJobInterface) {
            $job->setState(JobInterface::STATE_PERFORMING);
        }

        try {
            $jobInstance = $this->jobInstanceFactory->createPerformantJob($job);

            if (false === ($jobInstance instanceof PerformantJobInterface)) {
                throw new InvalidJobException(
                    'Job ' . $job->getId(). ' "' . get_class($jobInstance) . '" needs to implement Resque\JobInterface'
                );
            }

            $this->eventDispatcher->dispatch(
                ResqueJobEvents::BEFORE_PERFORM,
                new JobInstanceEvent($this, $job, $jobInstance)
            );

            $jobInstance->perform($job->getArguments());

        } catch (\Exception $exception) {
            $this->handleFailedJob($job, $exception);

            return false;
        }

        if ($job instanceof TrackableJobInterface) {
            $job->setState(JobInterface::STATE_COMPLETE);
        }

        $this->getLogger()->notice('{job} has successfully processed', array('job' => $job));

        $this->eventDispatcher->dispatch(ResqueJobEvents::PERFORMED, new WorkerJobEvent($this, $job));

        return true;
    }
367618
private function acquireLock($workerName, Job $job)
    {
        $affectedRows = $this->_em->getConnection()->executeUpdate(
            'UPDATE jms_jobs SET workerName = :worker WHERE id = :id AND workerName IS NULL',
            [
                'worker' => $workerName,
                'id' => $job->getId(),
            ]
        );

        if ($affectedRows > 0) {
            $job->setWorkerName($workerName);

            return true;
        }

        return false;
    }
133387
protected function unregisterJob(string $jobName, string $workerId) : bool
    {
        if (!isset($this->workerJobCapabilities[$jobName])) {
            return true;
        }
        if (($key = array_search($workerId, $this->workerJobCapabilities[$jobName])) !== false) {
            unset($this->workerJobCapabilities[$jobName][$key]);
        }
        if (empty($this->workerJobCapabilities[$jobName])) {
            unset($this->workerJobCapabilities[$jobName]);
        }
        return true;
    }