File tree Expand file tree Collapse file tree 1 file changed +2
-5
lines changed
Expand file tree Collapse file tree 1 file changed +2
-5
lines changed Original file line number Diff line number Diff line change @@ -100,6 +100,7 @@ public static function getTaskQueue(): ?SplQueue
100100 public static function runNonBlocking (mixed ...$ coroutines ): void
101101 {
102102 System::init ();
103+
103104 if (self ::$ taskQueue === null ) self ::$ taskQueue = new SplQueue ();
104105
105106 foreach ($ coroutines as $ coroutine ) {
@@ -137,10 +138,8 @@ private static function processCoroutine(mixed ...$coroutines): Closure
137138 if (is_callable ($ coroutine )) {
138139 $ coroutine = call_user_func ($ coroutine );
139140 }
140-
141141 !$ coroutine instanceof Generator ? call_user_func (fn () => $ coroutine ) : self ::schedule (new ChildCoroutine ($ coroutine ));
142142 }
143-
144143 self ::run ();
145144 };
146145 }
@@ -167,9 +166,7 @@ private static function schedule(ChildCoroutine $childCoroutine): void
167166 */
168167 public static function run (): void
169168 {
170- $ i = 0 ;
171- while (self ::$ taskQueue ?->isEmpty() === false ) {
172- if ($ i ++ >= 3 ) break ;
169+ if (self ::$ taskQueue ?->isEmpty() === false ) {
173170 $ coroutine = self ::$ taskQueue ->dequeue ();
174171 if ($ coroutine instanceof ChildCoroutine) {
175172 $ coroutine ->run ();
You can’t perform that action at this time.
0 commit comments