Skip to content

Commit

Permalink
Optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
walkor committed Jan 9, 2025
1 parent df67931 commit 5018ab3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/Events/Swoole.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ final class Swoole implements EventInterface
*/
private $errorHandler = null;

private bool $stopping = false;

/**
* Constructor.
*/
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/Events/Swow.php
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ public function run(): void
*/
public function stop(): void
{
Coroutine::killAll();
exit(0);
}

/**
Expand Down

0 comments on commit 5018ab3

Please sign in to comment.