src/drivers/gearman/Queue.php
public function run($repeat)
    {
        return $this->runWorker(function (callable $canContinue) use ($repeat) {
            $worker = new \GearmanWorker();
            $worker->addServer($this->host, $this->port);
            $worker->addFunction($this->channel, function (\GearmanJob $payload) {
                list($ttr, $message) = explode(';', $payload->workload(), 2);
                $this->handleMessage($payload->handle(), $message, $ttr, 1);
            });
            $worker->setTimeout($repeat ? 1000 : 1);
            while ($canContinue()) {
                $result = $worker->work();
                if (!$result && !$repeat) {
                    break;
                }
            }
        });
    }
public function run($repeat)
    {
        return $this->runWorker(function (callable $canContinue) use ($repeat) {
            $worker = new \GearmanWorker();
            $worker->addServer($this->host, $this->port);
            $worker->addFunction($this->channel, function (\GearmanJob $payload) {
                list($ttr, $message) = explode(';', $payload->workload(), 2);
                $this->handleMessage($payload->handle(), $message, $ttr, 1);
            });
            $worker->setTimeout($repeat ? 1000 : 1);
            while ($canContinue()) {
                $result = $worker->work();
                if (!$result && !$repeat) {
                    break;
                }
            }
        });
    }
Listens queue and runs each job.

@param bool $repeat whether to continue listening when queue is empty.
@return null|int exit code.
@internal for worker command only.
@since 2.0.2