您好,欢迎访问一九零五行业门户网

php 队列类 消息队列 thinkphp 队列 php队列处理高并

queue=$queue; } /** * @desc start queue * @param string $param new queue element */publicfunctionrun($param) {if(!is_array($this->queue)){ $this->strtoque();//将数组视为队列 } $currentlength=$this->countqueue(); //count the queue lengthecho$currentlength; echo$this->length.'
'; if($currentlength$this->length&&$this->length>0) { $this->queadd($param); }elseif($this->length==0) //如果为空队列,则将队列初始化为输入的队列 { $param=empty($param)?0:$param; $this->queue[]=$param; } else { for ($i=0;$i$currentlength-$this->length-1;$i++)//队列比规定的队列多,要删掉队首的元素,才能入队 { $this->queremove(); } $this->queadd($param); } return$this->queue; } /** * string like this 22,23,24 convert to array to do queue * @param string $string * @param string $delimiter */publicfunctionstrtoque(){if (empty($this->queue)) { $this->queue=array(); } else { $this->queue=explode($this->delimiter,$this->queue); } } /** * insert $node into queue * @param string $node */privatefunctionqueadd($node){ array_push($this->queue,$node); $this->countqueue(); } privatefunctionqueremove(){$node = array_shift($this->queue); $this->countqueue(); return$node; } privatefunctioncountqueue(){$currentlength= count($this->queue); return$currentlength; } function__destruct() {unset($this->queue); } } //example $str='88|89|90|56|23|45|69|23|20|100'; $obj=new queue ($str); $obj->length=8; // 队列元素长度 $obj->delimiter='|'; //如果队列是字符串,则元素直接的分隔符为| $a=$obj->run('91'); //要添加到队列中的元素 $a=$obj->run('92'); $a=$obj->run('93'); $a=$obj->run('94'); print_r($a);?>
').addclass('pre-numbering').hide(); $(this).addclass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadein(1700); }); }); 以上就介绍了php 队列类,包括了php,队列方面的内容,希望对php教程有兴趣的朋友有所帮助。
其它类似信息

推荐信息