Internal/WorkerRunner.php
public static function runDedicatedWorker($workerImpl)
    {
        $channel = self::getChannelFactory()->createChannel(Source::fromInput(), Sink::fromOutput());
        if ($workerImpl instanceof RawWorkerImplementationInterface) {
            $workerImpl->run($channel);
        } elseif ($workerImpl instanceof EventedWorkerImplementationInterface) {
            $loop = self::getLoop();
            Selectable::registerRead($loop, $channel, function () use ($loop, $channel, $workerImpl) {
                try {
                    $message = $channel->receiveMessage();
                } catch (IOException\UnderflowException $e) {
                    Selectable::unregisterRead($loop, $channel);
                    $workerImpl->onDisconnect($channel);

                    return;
                }
                $workerImpl->onMessage($message, $channel, null);
            });
            $workerImpl->setLoop($loop);
            $workerImpl->initialize();
            $workerImpl->onConnect($channel, null);
            $loop->run();
            $workerImpl->terminate();
        } else {
            throw new Exception\InvalidArgumentException('Bad worker implementation');
        }
    }
public static function runDedicatedWorker($workerImpl)
    {
        $channel = self::getChannelFactory()->createChannel(Source::fromInput(), Sink::fromOutput());
        if ($workerImpl instanceof RawWorkerImplementationInterface) {
            $workerImpl->run($channel);
        } elseif ($workerImpl instanceof EventedWorkerImplementationInterface) {
            $loop = self::getLoop();
            Selectable::registerRead($loop, $channel, function () use ($loop, $channel, $workerImpl) {
                try {
                    $message = $channel->receiveMessage();
                } catch (IOException\UnderflowException $e) {
                    Selectable::unregisterRead($loop, $channel);
                    $workerImpl->onDisconnect($channel);

                    return;
                }
                $workerImpl->onMessage($message, $channel, null);
            });
            $workerImpl->setLoop($loop);
            $workerImpl->initialize();
            $workerImpl->onConnect($channel, null);
            $loop->run();
            $workerImpl->terminate();
        } else {
            throw new Exception\InvalidArgumentException('Bad worker implementation');
        }
    }
@param RawWorkerImplementationInterface|EventedWorkerImplementationInterface $workerImpl

@throws Exception\InvalidArgumentException