mirror of
https://github.com/danog/parallel.git
synced 2024-11-27 04:44:56 +01:00
Consolodate process and thread contexts into Context namespace
This commit is contained in:
parent
33a5b89ff7
commit
3aff92fec4
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Amp\Parallel\Thread\Internal;
|
||||
namespace Amp\Parallel\Context\Internal;
|
||||
|
||||
use Amp\Loop;
|
||||
use Amp\Parallel\ContextException;
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Amp\Parallel\Process;
|
||||
namespace Amp\Parallel\Context;
|
||||
|
||||
use Amp\ByteStream;
|
||||
use Amp\Coroutine;
|
||||
@ -11,12 +11,12 @@ use Amp\Parallel\Sync\ChannelException;
|
||||
use Amp\Parallel\Sync\ChannelledStream;
|
||||
use Amp\Parallel\Sync\ExitResult;
|
||||
use Amp\Parallel\SynchronizationError;
|
||||
use Amp\Process\Process;
|
||||
use Amp\Process\Process as BaseProcess;
|
||||
use Amp\Promise;
|
||||
use function Amp\asyncCall;
|
||||
use function Amp\call;
|
||||
|
||||
class ChannelledProcess implements Context {
|
||||
class Process implements Context {
|
||||
/** @var \Amp\Process\Process */
|
||||
private $process;
|
||||
|
||||
@ -52,7 +52,7 @@ class ChannelledProcess implements Context {
|
||||
$processOptions = ["bypass_shell" => true];
|
||||
}
|
||||
|
||||
$this->process = new Process($command, $cwd, $env, $processOptions);
|
||||
$this->process = new BaseProcess($command, $cwd, $env, $processOptions);
|
||||
}
|
||||
|
||||
private function formatOptions(array $options) {
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Amp\Parallel\Thread;
|
||||
namespace Amp\Parallel\Context;
|
||||
|
||||
use Amp\Coroutine;
|
||||
use Amp\Loop;
|
||||
@ -61,7 +61,7 @@ class Thread implements Context {
|
||||
*
|
||||
* @return Thread The thread object that was spawned.
|
||||
*/
|
||||
public static function spawn(callable $function, ...$args) {
|
||||
public static function spawn(callable $function, ...$args): self {
|
||||
$thread = new self($function, ...$args);
|
||||
$thread->start();
|
||||
return $thread;
|
@ -1,8 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace Amp\Parallel\Thread;
|
||||
namespace Amp\Parallel\Sync;
|
||||
|
||||
use Amp\Parallel\Sync\Parcel;
|
||||
use Amp\Promise;
|
||||
use Amp\Success;
|
||||
use Amp\Sync\ThreadedMutex;
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace Amp\Parallel\Worker;
|
||||
|
||||
use Amp\Parallel\Process\ChannelledProcess;
|
||||
use Amp\Parallel\Context\Process;
|
||||
|
||||
/**
|
||||
* A worker thread that executes task objects.
|
||||
@ -20,6 +20,6 @@ class WorkerProcess extends AbstractWorker {
|
||||
$dir . "/worker",
|
||||
"-e" . $envClassName,
|
||||
];
|
||||
parent::__construct(new ChannelledProcess($script, $dir, $env));
|
||||
parent::__construct(new Process($script, $dir, $env));
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace Amp\Parallel\Worker;
|
||||
|
||||
use Amp\Parallel\Thread\Thread;
|
||||
use Amp\Parallel\Context\Thread;
|
||||
use Amp\Promise;
|
||||
|
||||
/**
|
||||
|
@ -1,10 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace Amp\Parallel\Test\Thread;
|
||||
namespace Amp\Parallel\Test\Context;
|
||||
|
||||
use Amp\Loop;
|
||||
use Amp\Parallel\Test\AbstractContextTest;
|
||||
use Amp\Parallel\Thread\Thread;
|
||||
use Amp\Parallel\Context\Thread;
|
||||
|
||||
/**
|
||||
* @group threading
|
@ -1,11 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace Amp\Parallel\Test\Thread;
|
||||
namespace Amp\Parallel\Test\Sync;
|
||||
|
||||
use Amp\Loop;
|
||||
use Amp\Parallel\Test\Sync\AbstractParcelTest;
|
||||
use Amp\Parallel\Thread\Thread;
|
||||
use Amp\Parallel\Thread\ThreadedParcel;
|
||||
use Amp\Parallel\Context\Thread;
|
||||
use Amp\Parallel\Sync\ThreadedParcel;
|
||||
|
||||
/**
|
||||
* @requires extension pthreads
|
Loading…
Reference in New Issue
Block a user