Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class MTDaemon{
- var $threads = 4;
- var $idlesleeptime = 3;
- var $run=true;
- var $slot=0;
- function __construct($threads = null, $idlesleeptime = null){
- if ($threads) {
- $this->threads=$threads;
- }
- if ($idlesleeptime) {
- $this->idlesleeptime=$idlesleeptime;
- }
- }
- function handle(){
- while($this->run){
- if ($this->slot>=$this->threads) {
- pcntl_wait(&$status);
- $this->slot--;
- }
- $next=$this->getNext($this->slot);
- if ($next==null) {
- continue;
- }
- if ($this->run==false) {
- break;
- }
- if(pcntl_fork()==0){
- $this->run($next,$this->slot);
- exit;
- }
- $this->slot++;
- }
- }
- function run($next,$slot){
- }
- function getNext($slot){
- }
- }
Add Comment
Please, Sign In to add comment