mirror of
https://github.com/danog/parallel.git
synced 2024-12-02 17:52:14 +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);
|
|
}
|