From 2d8707ae9eefb8f2ba1d7d7a0a170346e1a3d5c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A6=82=E6=9E=9C=E7=9A=84=E5=A6=82=E6=9E=9C?= Date: Mon, 1 Feb 2021 14:35:47 +0800 Subject: [PATCH] =?UTF-8?q?onloop=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/CoroutineRunner/Runner.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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;