php开启子进程处理

$pageNum = ceil($totalNum/$pageSize);
for($page=1;$page<=$pageNum;$page++){
    $this->o_pcntl->tps_pcntl_wait('$this->o_cron->doNewMemberSharPage(\''.$page.'\',\''.$pageSize.'\');');//用子进程处理每一页
}


<?php

class o_pcntl extends CI_Model {

    function __construct() {
        parent::__construct();
    }

    public function tps_pcntl_wait($childProcessCode){

        $pid = pcntl_fork();
        if($pid>0){

            pcntl_wait($status);
            @$this->db->reconnect();
        }elseif($pid==0){

            eval($childProcessCode);
            exit;
        }else{
            die('Cannot fork.');
        }
    }
}

 

posted @ 2017-03-26 17:56  brady-wang  阅读(1636)  评论(0编辑  收藏  举报