Skip to content

Commit

Permalink
onloop优化
Browse files Browse the repository at this point in the history
  • Loading branch information
kiss291323003 committed Feb 1, 2021
1 parent 8b1751e commit 2d8707a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/CoroutineRunner/Runner.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ function start(float $waitTime = 30)
}
$start = time();
while ($waitTime > 0){
if(is_callable($this->onLoop)){
call_user_func($this->onLoop,$this);
}
if($this->runningNum <= $this->concurrency && !$this->taskChannel->isEmpty()){
$task = $this->taskChannel->pop(0.01);
if($task instanceof Task){
Expand Down Expand Up @@ -105,9 +108,6 @@ function start(float $waitTime = 30)
Coroutine::sleep(0.01);
}
}
if(is_callable($this->onLoop)){
call_user_func($this->onLoop,$this);
}
}
$this->isRunning = false;
$this->runningNum = 0;
Expand Down

0 comments on commit 2d8707a

Please sign in to comment.