diff --git a/src/CoroutineRunner/Runner.php b/src/CoroutineRunner/Runner.php index b1c8065..02f6a78 100644 --- a/src/CoroutineRunner/Runner.php +++ b/src/CoroutineRunner/Runner.php @@ -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){ @@ -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;