This commit is contained in:
2022-10-11 15:51:01 +08:00
parent 5d0c019bd5
commit 52624c4542
+6 -1
View File
@@ -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;
}