current() публичный статический Метод

public static current ( ) : Process
Результат Process
Пример #1
0
 public function __construct($config)
 {
     $this->_currentProcess = Process::current();
     $this->_config = $config;
     $this->_timeout = $config->getTimeout();
     $this->_onTimeoutCallback = $config->getOnTimeout();
 }
Пример #2
0
<?php

/**
 * @author bigbigant
 */
require __DIR__ . '/bootstrap.inc.php';
use Comos\Qpm\Process\Process;
echo "The program will run in background in 50 seconds.\nYou can see the prints in " . __FILE__ . ".log\n";
//实际的工作内容
function work()
{
    $i = 10;
    while (--$i) {
        file_put_contents(__FILE__ . '.log', date('Y-m-d H:i:s') . "\n", FILE_APPEND);
        sleep(5);
    }
}
//通过回调启动子进程
Process::current()->fork(function () {
    //子进程将自己转入后台
    Process::current()->toBackground();
    work();
});
Пример #3
0
/**
 * worker
 * 
 * executes in child Process
 */
function worker()
{
    sleep(5);
    $msg = sprintf("PID: %d\tPPID:%d\n", Process::current()->getPid(), Process::current()->getParent()->getPid());
    file_put_contents(__FILE__ . '.log', $msg, FILE_APPEND);
}
Пример #4
0
 /**
  *
  * @param Config[] $configs            
  */
 public function __construct($configs)
 {
     $this->_currentProcess = Process::current();
     $this->_configs = $configs;
 }