當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。