Skip to content

Commit e776e90

Browse files
authored
Update CoroutineGen.php
1 parent b3d6673 commit e776e90

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

src/vennv/vapm/CoroutineGen.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff 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();

0 commit comments

Comments
 (0)