cii-text-analysis/vendor/amphp/parallel/lib/Context/DefaultContextFactory.php
Jéremy Munsch f68d2ac333
premier poc
2026-02-11 08:24:04 +01:00

36 lines
781 B
PHP

<?php
namespace Amp\Parallel\Context;
use Amp\Promise;
class DefaultContextFactory implements ContextFactory
{
public function create($script): Context
{
/**
* Creates a thread if ext-parallel is installed, otherwise creates a child process.
*
* @inheritdoc
*/
if (Parallel::isSupported()) {
return new Parallel($script);
}
return new Process($script);
}
/**
* Creates and starts a thread if ext-parallel is installed, otherwise creates a child process.
*
* @inheritdoc
*/
public function run($script): Promise
{
if (Parallel::isSupported()) {
return Parallel::run($script);
}
return Process::run($script);
}
}