OpenSwoole\Process::statQueue ( void ) : array

Latest version: pecl install openswoole-22.1.2 | composer require openswoole/core:22.1.5

Declaration

<?php OpenSwoole\Process::statQueue ( void ) : array

Parameters

Return

stat

Message queue stat

<?php
array(
    "queue_num" => 10, // number of task in the queue
    "queue_bytes" => 161, // the total bytes of data in the queue
);

Description

Get the stats of the message queue used as the communication method between processes.

Example

<?php
$child_num = 3;
$child_processes = [];
for($i = 1; $i <= $child_num; $i++) {
    $process = new OpenSwoole\Process(function($worker){
        echo "the pid of child process is " . $worker->pid . "\n";

        $worker->name("php child process");

        exit(0);
    }, FALSE);

    $res = $process->useQueue(0, 2);

    $pid = $process->start();

    $child_processes[(string)$pid] = $process;
}

foreach($child_processes as $pid => $child_process) {
    $child_process->push("From main process : Hello child process {$pid}\n");

    echo "the stat of queue : ";

    var_dump($child_process->statqueue());
}
Last updated on September 1, 2022