/
githubmirror
/
framework
Обзор
Документация
Войти
/
githubmirror
/
framework
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
13.x
src/Illuminate/Concurrency/ForkDriver.php
41 строка
1 KB
Daniel Polito
feat: support concurrency run timeouts (#60105)
13 май 2026, 16:44
Не верифицирован
13 май 2026, 16:44
0d89d7c
Код
Авторство
О чём код?
<?php namespace Illuminate\Concurrency; use Carbon\CarbonInterval; use Closure; use Illuminate\Contracts\Concurrency\Driver; use Illuminate\Support\Arr; use Illuminate\Support\Defer\DeferredCallback; use Spatie\Fork\Fork; use function Illuminate\Support\defer; class ForkDriver implements Driver { /** * Run the given tasks concurrently and return an array containing the results. */ public function run(Closure|array $tasks, CarbonInterval|int|null $timeout = null): array { $tasks = Arr::wrap($tasks); $keys = array_keys($tasks); $values = array_values($tasks); /** @phpstan-ignore class.notFound (spatie/fork is not installed as it is practically incompatible with Windows) */ $results = Fork::new()->run(...$values); ksort($results); return array_combine($keys, $results); } /** * Start the given tasks in the background after the current task has finished. */ public function defer(Closure|array $tasks): DeferredCallback { return defer(fn () => $this->run($tasks)); } }