From 5018ab3c6307f299801717e898ef5441f4fc88b6 Mon Sep 17 00:00:00 2001 From: walkor Date: Thu, 9 Jan 2025 09:14:49 +0800 Subject: [PATCH] Optimization --- src/Events/Swoole.php | 6 ++++++ src/Events/Swow.php | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Events/Swoole.php b/src/Events/Swoole.php index 41f08214c..9bdde9175 100644 --- a/src/Events/Swoole.php +++ b/src/Events/Swoole.php @@ -48,6 +48,8 @@ final class Swoole implements EventInterface */ private $errorHandler = null; + private bool $stopping = false; + /** * Constructor. */ @@ -220,6 +222,10 @@ public function run(): void */ public function stop(): void { + if ($this->stopping) { + return; + } + $this->stopping = true; // Cancel all coroutines before Event::exit foreach (Coroutine::listCoroutines() as $coroutine) { Coroutine::cancel($coroutine); diff --git a/src/Events/Swow.php b/src/Events/Swow.php index 109b2211b..445763378 100644 --- a/src/Events/Swow.php +++ b/src/Events/Swow.php @@ -266,7 +266,7 @@ public function run(): void */ public function stop(): void { - Coroutine::killAll(); + exit(0); } /**