00001 <?php 00002 00003 /* 00004 * This file is part of the PEIP package. 00005 * (c) 2010 Timo Michna <timomichna/yahoo.de> 00006 * 00007 * For the full copyright and license information, please view the LICENSE 00008 * file that was distributed with this source code. 00009 */ 00010 00022 class PEIP_Queue_Channel 00023 extends PEIP_ABS_Pollable_Channel { 00024 00025 protected 00026 $capacity, 00027 $queue; 00028 00029 00035 public function __construct($capacity = -1){ 00036 $this->setCapacity((int)$capacity); 00037 $this->queue = new SplQueue(); 00038 } 00039 00040 00045 public function getMessageCount(){ 00046 return count($this->messages); 00047 } 00048 00049 00054 public function getCapacity(){ 00055 return $this->capacity; 00056 } 00057 00058 00064 public function setCapacity($capacity){ 00065 $this->capacity = $capacity; 00066 } 00067 00068 00074 protected function doSend(PEIP_INF_Message $message){ 00075 if($this->capacity < 1 || $this->getMessageCount() <= $this->getCapacity()){ 00076 $this->queue->enqueque($message); 00077 }else{ 00078 throw new Exception('Not implemented yet.'); 00079 } 00080 } 00081 }