Esempio n. 1
0
 /**
  * worker master - Chan
  */
 function workerChan()
 {
     $start = microtime(true);
     echo "\nworkerChan start at {$start}";
     $jobs = array('0' => array('1', '2', '3'), '1' => array('1', '2', '3'), '2' => array('1', '2', '3'));
     if ($jobs) {
         $chanCnt = count($jobs);
         if ($chanCnt && $jobs) {
             $jobCnt = count($jobs, COUNT_RECURSIVE);
             $chan = new Chan("demoWorker", $jobs);
             $chan->waiting();
             $stop = microtime(true);
             $cost = $stop - $start;
             echo "\nworkerChan {$jobCnt} jobs done at {$stop}";
             echo "\nworkerChan {$jobCnt} cost time = {$cost}";
         }
     } else {
         //for daemon mode
         echo "\nworkerChan no job and sleep 5s";
         sleep(5);
     }
     $end = microtime(true);
     echo "\nworkerChan end at {$end}";
 }