当前位置: 首页>>代码示例>>PHP>>正文


PHP swoole_process::exit方法代码示例

本文整理汇总了PHP中swoole_process::exit方法的典型用法代码示例。如果您正苦于以下问题:PHP swoole_process::exit方法的具体用法?PHP swoole_process::exit怎么用?PHP swoole_process::exit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在swoole_process的用法示例。


在下文中一共展示了swoole_process::exit方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: callback_function

function callback_function(swoole_process $worker)
{
    //echo "Worker: start. PID=".$worker->pid."\n";
    //recv data from master
    $recv = $worker->pop();
    echo "From Master: {$recv}\n";
    sleep(2);
    $worker->exit(0);
}
开发者ID:chenwenbin928,项目名称:swoole-src,代码行数:9,代码来源:msgqueue.php

示例2: child_sync

function child_sync(swoole_process $worker)
{
    //echo "Worker: start. PID=".$worker->pid."\n";
    //recv data from master
    $recv = $worker->read();
    echo "From Master: {$recv}\n";
    //send data to master
    $worker->write("hello master\n");
    sleep(2);
    $worker->exit(0);
}
开发者ID:zzjin,项目名称:swoole-src,代码行数:11,代码来源:worker.php

示例3: callback_process_function

function callback_process_function(swoole_process $worker)
{
    set_time_limit(300);
    $task = json_decode($worker->read(), true);
    $worker->name('crontab.php worker=' . $task['uniqid']);
    $Handle = new TimingCall_Handle($task);
    $Handle->upNextExecuteTime();
    $Handle->refreshStatistics();
    $Handle->Execute();
    $worker->exit(0);
}
开发者ID:imdaqian,项目名称:Hi-Timed,代码行数:11,代码来源:cmd.php

示例4: callback_function

function callback_function(swoole_process $worker)
{
    //echo "Worker: start. PID=".$worker->pid."\n";
    //recv data from master
    $cnt = 0;
    while ($cnt < 2) {
        // 如果队列里没有数据,则pop方法阻塞等待
        $recv = $worker->pop();
        echo "From Master: {$recv}\n";
        $cnt++;
    }
    sleep(1);
    $worker->exit(0);
}
开发者ID:silentred,项目名称:learning-path,代码行数:14,代码来源:queue.php

示例5: onTmpProcess

 public function onTmpProcess(swoole_process $worker)
 {
     $cmd = $worker->read();
     $handle = popen($cmd, 'r');
     swoole_event_add($worker->pipe, function () use($worker, $handle) {
         $cmd = $worker->read();
         if ($cmd == 'exit') {
             $worker->exit();
         }
         fwrite($handle, $cmd);
     });
     while (!feof($handle)) {
         $buffer = fread($handle, 18192);
         echo $buffer;
     }
 }
开发者ID:jinchunguang,项目名称:swoole-doc,代码行数:16,代码来源:shell_server.php

示例6: while

    global $workers;
    $worker = $workers[$pipe];
    $data = $worker->read();
    if ($data == false) {
        //表示子进程已关闭,回收它
        $status = swoole_process::wait();
        echo "Worker#{$status['pid']} exit\n";
    } else {
        echo "RECV: " . $data;
    }
}
//循环创建进程
for ($i = 0; $i < $worker_num; $i++) {
    $process = new swoole_process(function (swoole_process $process) {
        $i = 1;
        while ($i++) {
            $process->write("Worker#{$process->id}: hello master\n");
            if ($i > 5 and $process->id == 1) {
                $process->exit();
            }
            sleep(1);
        }
    });
    $process->id = $i;
    $pid = $process->start();
    $workers[$process->pipe] = $process;
}
//将子进程的管道加入EventLoop
foreach ($workers as $process) {
    swoole_event_add($process->pipe, 'onReceive');
}
开发者ID:sophia2152,项目名称:swoole-src,代码行数:31,代码来源:async_master.php


注:本文中的swoole_process::exit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。