Process Manager

Notice: the documentation is suitable for PHP extension swoole until v4.7.1, we only support PHP extension openswoole from v4.7.1

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

Swoole\Process\ProcessManager is an alias of Swoole\Process\Manager.

since v4.5.3

Methods

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

    Example

    <?php
    $pm = new Swoole\Process\Manager();
    $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();