mirror of
https://github.com/danog/parallel.git
synced 2024-12-12 09:09:35 +01:00
34 lines
497 B
PHP
34 lines
497 B
PHP
|
<?php
|
||
|
|
||
|
namespace Amp\Parallel\Context;
|
||
|
|
||
|
use Amp\Promise;
|
||
|
|
||
|
/**
|
||
|
* @param string|string[] $script
|
||
|
*
|
||
|
* @return Context
|
||
|
*/
|
||
|
function create($script): Context
|
||
|
{
|
||
|
if (Parallel::isSupported()) {
|
||
|
return new Parallel($script);
|
||
|
}
|
||
|
|
||
|
return new Process($script);
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @param string|string[] $script
|
||
|
*
|
||
|
* @return Promise<Context>
|
||
|
*/
|
||
|
function run($script): Promise
|
||
|
{
|
||
|
if (Parallel::isSupported()) {
|
||
|
return Parallel::run($script);
|
||
|
}
|
||
|
|
||
|
return Process::run($script);
|
||
|
}
|