Process Manager

Execute your function with multiple processes managed by the process manager.

since v4.5.3

Methods

  • Swoole\Process\ProcessManager::__construct
  • Swoole\Process\ProcessManager->add
  • Swoole\Process\ProcessManager->addBatch
  • Swoole\Process\ProcessManager->setIPCType
  • Swoole\Process\ProcessManager->getIPCType
  • Swoole\Process\ProcessManager->setMsgQueueKey
  • Swoole\Process\ProcessManager->getMsgQueueKey
  • Swoole\Process\ProcessManager->start

    Example

    <?php
    $pm = new Swoole\Process\ProcessManager();
    $atomic = new Atomic(0);
    $pm->add(function (Pool $pool, int $workerId) use ($atomic) {
        usleep(100000);
        $atomic->wakeup();
    });
    $pm->add(function (Pool $pool, int $workerId) use ($atomic) {
        $atomic->wait(1.5);
        $pool->shutdown();
    });
    $pm->start();