From 52624c454201b6c8900cf9a572058b732b4a0aa8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=91=E6=9E=97?= Date: Tue, 11 Oct 2022 15:51:01 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=98=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kiri-actor/Actor.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/kiri-actor/Actor.php b/kiri-actor/Actor.php index 6907e112..9bedeb67 100644 --- a/kiri-actor/Actor.php +++ b/kiri-actor/Actor.php @@ -3,6 +3,7 @@ namespace Kiri\Actor; use JsonSerializable; +use Swoole\Coroutine; use Swoole\Coroutine\Channel; abstract class Actor implements ActorInterface, JsonSerializable @@ -85,7 +86,11 @@ abstract class Actor implements ActorInterface, JsonSerializable */ public static function newActor($id): static { - return new static($id); + $actor = new static($id); + Coroutine::create(function (Actor $actor) { + $actor->run(); + }, $actor); + return $actor; }