File tree Expand file tree Collapse file tree 3 files changed +28
-1
lines changed
Expand file tree Collapse file tree 3 files changed +28
-1
lines changed Original file line number Diff line number Diff line change 22composer.lock
33* .cache
44* .log
5- .idea
5+ .idea
6+ .bashrc
Original file line number Diff line number Diff line change @@ -147,4 +147,12 @@ public static function exists(int $id): bool
147147 {
148148 return parent ::get ($ id ) !== null ;
149149 }
150+
151+ /**
152+ * @return iterable<int>
153+ */
154+ public static function list (): iterable
155+ {
156+ yield from array_keys (parent ::getAll ());
157+ }
150158}
Original file line number Diff line number Diff line change @@ -176,4 +176,22 @@ public function testCoroutineResumeById()
176176 $ this ->assertSame (3 , $ channel ->pop ());
177177 $ this ->assertSame (5 , $ channel ->pop ());
178178 }
179+
180+ public function testCoroutineList ()
181+ {
182+ $ list = Coroutine::list ();
183+ $ this ->assertIsIterable ($ list );
184+ $ this ->assertContains (Coroutine::id (), $ list );
185+
186+ Coroutine::create (function () {
187+ sleep (1 );
188+ });
189+ Coroutine::create (function () {
190+ sleep (1 );
191+ });
192+ Coroutine::create (function () {
193+ sleep (1 );
194+ });
195+ $ this ->assertEquals (5 , iterator_count (Coroutine::list ()));
196+ }
179197}
You can’t perform that action at this time.
0 commit comments