minor changes
This commit is contained in:
parent
ac2a584b8d
commit
17ab29ce00
|
@ -92,7 +92,7 @@ class Thread
|
||||||
*/
|
*/
|
||||||
public function __construct( $runnable = null )
|
public function __construct( $runnable = null )
|
||||||
{
|
{
|
||||||
if(!Thread::isAvailable)throw new Exception("Threads not supported");
|
if(!Thread::isAvailable() )throw new Exception("Threads not supported");
|
||||||
if ( $runnable !== null ) {
|
if ( $runnable !== null ) {
|
||||||
$this->setRunnable($runnable);
|
$this->setRunnable($runnable);
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,22 +70,22 @@ class ThreadQueue {
|
||||||
$this->cleanup();
|
$this->cleanup();
|
||||||
|
|
||||||
if( (count($this->threads) < $this->queueSize) && count($this->jobs) ){
|
if( (count($this->threads) < $this->queueSize) && count($this->jobs) ){
|
||||||
$this->threads[] = $szal = new zsThread($this->callable);
|
$this->threads[] = $szal = new Thread($this->callable);
|
||||||
$szal->start( array_shift($this->jobs) );
|
$szal->start( array_shift($this->jobs) );
|
||||||
}
|
}
|
||||||
|
|
||||||
usleep(ThreadQueue::TICK_DELAY);
|
usleep(ThreadQueue::TICK_DELAY);
|
||||||
return $this->size();
|
return $this->queueSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* returns queue size
|
* returns queue size with waiting jobs
|
||||||
*
|
*
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public function size(){
|
public function queueSize(){
|
||||||
return count($this->jobs);
|
return count($this->jobs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,7 +106,7 @@ class ThreadQueue {
|
||||||
* @return int number of removed jobs
|
* @return int number of removed jobs
|
||||||
*/
|
*/
|
||||||
public function flush(){
|
public function flush(){
|
||||||
$size = $this->size();
|
$size = $this->queueSize();
|
||||||
$this->jobs = array();
|
$this->jobs = array();
|
||||||
return $size;
|
return $size;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue