private static function all(\Traversable&\Countable $windows): \Iterator { $processes = new \WeakMap(); while ($windows->count() > 0) { foreach ($windows as $runnable) { $process = ($processes[$runnable] ??= new \Fiber($runnable->run(...))); switch (false) { case $process->isStarted(): yield $process->start(); break; case $process->isTerminated(): yield $process->resume(); break; default: unset($processes[$runnable]); } } } }
сегодня?
Обсуждают сегодня