Rename to Parallel

This commit is contained in:
Aaron Piotrowski 2016-08-23 16:47:40 -05:00
parent b924fc2b6e
commit ce25a0179d
91 changed files with 265 additions and 266 deletions

View File

@ -1,6 +1,6 @@
# Concurrency for Amp
# Parallel Processing for Amp
**True concurrency using native threading and multiprocessing for parallelizing code, *without* blocking.**
**True parallel processing using native threading and multiprocessing for parallelizing code, *without* blocking.**
This library is a component for [Amp](https://amphp.org) that provides native threading, multiprocessing, process synchronization, shared memory, and task workers. Like other Amp components, this library uses Coroutines built from Awaitables and [Generators](http://www.php.net/manual/en/language.generators.overview.php) to make writing asynchronous code more like writing synchronous code.
@ -25,7 +25,7 @@ The recommended way to install is with the [Composer](http://getcomposer.org/) p
Run the following command to use this package in your project:
```bash
composer require amphp/concurrent
composer require amphp/parallel
```
You can also manually edit `composer.json` to add this library as a project requirement.
@ -34,7 +34,7 @@ You can also manually edit `composer.json` to add this library as a project requ
// composer.json
{
"require": {
"amphp/concurrent": "dev-master"
"amphp/parallel": "dev-master"
}
}
```

View File

@ -1,9 +1,9 @@
#!/usr/bin/env php
<?php declare(strict_types = 1);
use Amp\Concurrent\{ ChannelException, SerializationException} ;
use Amp\Concurrent\Sync\{ ChannelledStream, Internal\ExitFailure, Internal\ExitSuccess };
use Amp\Concurrent\Worker\{ BasicEnvironment, Internal\TaskRunner };
use Amp\Parallel\{ ChannelException, SerializationException} ;
use Amp\Parallel\Sync\{ ChannelledStream, Internal\ExitFailure, Internal\ExitSuccess };
use Amp\Parallel\Worker\{ BasicEnvironment, Internal\TaskRunner };
use Amp\Socket\Socket;
@cli_set_process_title("amp-worker");

View File

@ -1,6 +1,6 @@
{
"name": "amphp/concurrent",
"description": "Concurrency component for Amp.",
"name": "amphp/parallel",
"description": "Parallel processing component for Amp.",
"keywords": [
"asynchronous",
"async",
@ -42,7 +42,7 @@
},
"autoload": {
"psr-4": {
"Amp\\Concurrent\\": "lib"
"Amp\\Parallel\\": "lib"
},
"files": [
"lib/Worker/functions.php"
@ -50,8 +50,8 @@
},
"autoload-dev": {
"psr-4": {
"Amp\\Concurrent\\Example\\": "examples",
"Amp\\Concurrent\\Test\\": "test"
"Amp\\Parallel\\Example\\": "examples",
"Amp\\Parallel\\Test\\": "test"
}
}
}

View File

@ -1,7 +1,7 @@
<?php
namespace Amp\Concurrent\Example;
namespace Amp\Parallel\Example;
use Amp\Concurrent\Worker\{ Environment, Task };
use Amp\Parallel\Worker\{ Environment, Task };
class BlockingTask implements Task {
/**

View File

@ -2,7 +2,7 @@
<?php
require dirname(__DIR__).'/vendor/autoload.php';
use Amp\Concurrent\Forking\Fork;
use Amp\Parallel\Forking\Fork;
Amp\execute(function () {
$context = Fork::spawn(function () {

View File

@ -2,7 +2,7 @@
<?php
require dirname(__DIR__).'/vendor/autoload.php';
use Amp\Concurrent\Threading\Thread;
use Amp\Parallel\Threading\Thread;
use Amp\Pause;
Amp\execute(function () {

View File

@ -2,9 +2,9 @@
<?php
require dirname(__DIR__).'/vendor/autoload.php';
use Amp\Concurrent\Worker\DefaultPool;
use Amp\Parallel\Worker\DefaultPool;
use Amp\Coroutine;
use Amp\Concurrent\Example\BlockingTask;
use Amp\Parallel\Example\BlockingTask;
Amp\execute(function() {
$timer = Amp\repeat(100, function () {

View File

@ -2,8 +2,8 @@
<?php
require dirname(__DIR__).'/vendor/autoload.php';
use Amp\Concurrent\Worker\DefaultWorkerFactory;
use Amp\Concurrent\Example\BlockingTask;
use Amp\Parallel\Worker\DefaultWorkerFactory;
use Amp\Parallel\Example\BlockingTask;
Amp\execute(function () {
$factory = new DefaultWorkerFactory();

View File

@ -1,6 +1,6 @@
<?php declare(strict_types = 1);
namespace Amp\Concurrent;
namespace Amp\Parallel;
class ChannelException extends \Exception {
public function __construct(string $message, \Throwable $previous = null) {

View File

@ -1,6 +1,6 @@
<?php declare(strict_types = 1);
namespace Amp\Concurrent;
namespace Amp\Parallel;
use Interop\Async\Awaitable;

View File

@ -1,5 +1,5 @@
<?php declare(strict_types = 1);
namespace Amp\Concurrent;
namespace Amp\Parallel;
class ContextException extends \Exception {}

View File

@ -1,8 +1,9 @@
<?php declare(strict_types = 1);
namespace Amp\Concurrent\Forking;
namespace Amp\Parallel\Forking;
use Amp\Concurrent\{
use Amp\Coroutine;
use Amp\Parallel\{
ContextException,
ChannelException,
Process,
@ -11,9 +12,8 @@ use Amp\Concurrent\{
Strand,
SynchronizationError
};
use Amp\Concurrent\Sync\{ Channel, ChannelledStream };
use Amp\Concurrent\Sync\Internal\{ ExitFailure, ExitStatus, ExitSuccess };
use Amp\Coroutine;
use Amp\Parallel\Sync\{ Channel, ChannelledStream };
use Amp\Parallel\Sync\Internal\{ ExitFailure, ExitStatus, ExitSuccess };
use Amp\Socket\Socket;
use Interop\Async\Awaitable;
@ -22,7 +22,7 @@ use Interop\Async\Awaitable;
*/
class Fork implements Process, Strand {
/**
* @var \Amp\Concurrent\Sync\Channel A channel for communicating with the child.
* @var \Amp\Parallel\Sync\Channel A channel for communicating with the child.
*/
private $channel;
@ -65,7 +65,7 @@ class Fork implements Process, Strand {
*
* @param callable $function A callable to invoke in the process.
*
* @return \Amp\Concurrent\Forking\Fork The process object that was spawned.
* @return \Amp\Parallel\Forking\Fork The process object that was spawned.
*/
public static function spawn(callable $function, ...$args): self {
$fork = new self($function, ...$args);
@ -163,7 +163,7 @@ class Fork implements Process, Strand {
/**
* Starts the context execution.
*
* @throws \Amp\Concurrent\ContextException If forking fails.
* @throws \Amp\Parallel\ContextException If forking fails.
* @throws \Amp\Socket\SocketException If creating a socket pair fails.
*/
public function start() {
@ -206,7 +206,7 @@ class Fork implements Process, Strand {
*
* This method is run only on the child.
*
* @param \Amp\Concurrent\Sync\Channel $channel
* @param \Amp\Parallel\Sync\Channel $channel
*
* @return \Generator
*
@ -272,7 +272,7 @@ class Fork implements Process, Strand {
/**
* @param int $signo
*
* @throws \Amp\Concurrent\StatusError
* @throws \Amp\Parallel\StatusError
*/
public function signal(int $signo) {
if (0 === $this->pid) {
@ -288,8 +288,8 @@ class Fork implements Process, Strand {
*
* @return \Interop\Async\Awaitable<int>
*
* @throws \Amp\Concurrent\StatusError Thrown if the context has not been started.
* @throws \Amp\Concurrent\SynchronizationError Thrown if an exit status object is not received.
* @throws \Amp\Parallel\StatusError Thrown if the context has not been started.
* @throws \Amp\Parallel\SynchronizationError Thrown if an exit status object is not received.
*/
public function join(): Awaitable {
if (null === $this->channel) {
@ -304,7 +304,7 @@ class Fork implements Process, Strand {
*
* @return \Generator
*
* @throws \Amp\Concurrent\SynchronizationError
* @throws \Amp\Parallel\SynchronizationError
*/
private function doJoin(): \Generator {
try {

View File

@ -1,5 +1,5 @@
<?php declare(strict_types = 1);
namespace Amp\Concurrent;
namespace Amp\Parallel;
class LockAlreadyReleasedError extends \Error {}

View File

@ -1,5 +1,5 @@
<?php declare(strict_types = 1);
namespace Amp\Concurrent;
namespace Amp\Parallel;
class MutexException extends \Exception {}

View File

@ -1,6 +1,6 @@
<?php declare(strict_types = 1);
namespace Amp\Concurrent;
namespace Amp\Parallel;
class PanicError extends \Error {
/**

View File

@ -1,6 +1,6 @@
<?php declare(strict_types = 1);
namespace Amp\Concurrent;
namespace Amp\Parallel;
interface Process extends Context {
/**
@ -11,7 +11,7 @@ interface Process extends Context {
/**
* @param int $signo
*
* @throws \Amp\Concurrent\StatusError
* @throws \Amp\Parallel\StatusError
*/
public function signal(int $signo);
}

View File

@ -1,19 +1,19 @@
<?php declare(strict_types = 1);
namespace Amp\Concurrent\Process;
namespace Amp\Parallel\Process;
use Amp\Concurrent\{ Process as ProcessContext, StatusError, Strand, SynchronizationError };
use Amp\Concurrent\Sync\{ ChannelledStream, Internal\ExitStatus };
use Amp\Parallel\{ Process as ProcessContext, StatusError, Strand, SynchronizationError };
use Amp\Parallel\Sync\{ ChannelledStream, Internal\ExitStatus };
use Interop\Async\Awaitable;
class ChannelledProcess implements ProcessContext, Strand {
/**
* @var \Amp\Concurrent\Process\Process
* @var \Amp\Parallel\Process\Process
*/
private $process;
/**
* @var \Amp\Concurrent\Sync\Channel
* @var \Amp\Parallel\Sync\Channel
*/
private $channel;

View File

@ -1,9 +1,9 @@
<?php declare(strict_types = 1);
namespace Amp\Concurrent\Process;
namespace Amp\Parallel\Process;
use Amp\Deferred;
use Amp\Concurrent\{ ContextException, Process as ProcessContext, StatusError };
use Amp\Parallel\{ ContextException, Process as ProcessContext, StatusError };
use Amp\Socket\Socket;
use Amp\Stream\Stream;
use Interop\Async\{ Awaitable, Loop };
@ -128,8 +128,8 @@ class Process implements ProcessContext {
}
/**
* @throws \Amp\Concurrent\ContextException If starting the process fails.
* @throws \Amp\Concurrent\StatusError If the process is already running.
* @throws \Amp\Parallel\ContextException If starting the process fails.
* @throws \Amp\Parallel\StatusError If the process is already running.
*/
public function start() {
if (null !== $this->deferred) {
@ -212,7 +212,7 @@ class Process implements ProcessContext {
/**
* @return \Interop\Async\Awaitable<int> Resolves with exit status.
*
* @throws \Amp\Concurrent\StatusError If the process has not been started.
* @throws \Amp\Parallel\StatusError If the process has not been started.
*/
public function join(): Awaitable {
if ($this->deferred === null) {
@ -249,7 +249,7 @@ class Process implements ProcessContext {
*
* @param int $signo Signal number to send to process.
*
* @throws \Amp\Concurrent\StatusError If the process is not running.
* @throws \Amp\Parallel\StatusError If the process is not running.
*/
public function signal(int $signo) {
if (!$this->isRunning()) {
@ -323,7 +323,7 @@ class Process implements ProcessContext {
*
* @return \Amp\Stream\Stream
*
* @throws \Amp\Concurrent\StatusError If the process is not running.
* @throws \Amp\Parallel\StatusError If the process is not running.
*/
public function getStdIn(): Stream {
if ($this->stdin === null) {
@ -338,7 +338,7 @@ class Process implements ProcessContext {
*
* @return \Amp\Stream\Stream
*
* @throws \Amp\Concurrent\StatusError If the process is not running.
* @throws \Amp\Parallel\StatusError If the process is not running.
*/
public function getStdOut(): Stream {
if ($this->stdout === null) {
@ -353,7 +353,7 @@ class Process implements ProcessContext {
*
* @return \Amp\Stream\Stream
*
* @throws \Amp\Concurrent\StatusError If the process is not running.
* @throws \Amp\Parallel\StatusError If the process is not running.
*/
public function getStdErr(): Stream {
if ($this->stderr === null) {

View File

@ -1,5 +1,5 @@
<?php declare(strict_types = 1);
namespace Amp\Concurrent;
namespace Amp\Parallel;
class SemaphoreException extends \Exception {}

View File

@ -1,5 +1,5 @@
<?php declare(strict_types = 1);
namespace Amp\Concurrent;
namespace Amp\Parallel;
class SerializationException extends ChannelException {}

View File

@ -1,5 +1,5 @@
<?php declare(strict_types = 1);
namespace Amp\Concurrent;
namespace Amp\Parallel;
class SharedMemoryException extends \Exception {}

View File

@ -1,5 +1,5 @@
<?php declare(strict_types = 1);
namespace Amp\Concurrent;
namespace Amp\Parallel;
class StatusError extends \Error {}

View File

@ -1,5 +1,5 @@
<?php declare(strict_types = 1);
namespace Amp\Concurrent;
namespace Amp\Parallel;
interface Strand extends Context, Sync\Channel {}

View File

@ -1,6 +1,6 @@
<?php declare(strict_types = 1);
namespace Amp\Concurrent\Sync;
namespace Amp\Parallel\Sync;
use Interop\Async\Awaitable;
@ -11,11 +11,11 @@ interface Channel {
/**
* @return \Interop\Async\Awaitable<mixed>
*
* @throws \Amp\Concurrent\StatusError Thrown if the context has not been started.
* @throws \Amp\Concurrent\SynchronizationError If the context has not been started or the context
* @throws \Amp\Parallel\StatusError Thrown if the context has not been started.
* @throws \Amp\Parallel\SynchronizationError If the context has not been started or the context
* unexpectedly ends.
* @throws \Amp\Concurrent\ChannelException If receiving from the channel fails.
* @throws \Amp\Concurrent\SerializationException If unserializing the data fails.
* @throws \Amp\Parallel\ChannelException If receiving from the channel fails.
* @throws \Amp\Parallel\SerializationException If unserializing the data fails.
*/
public function receive(): Awaitable;
@ -24,12 +24,12 @@ interface Channel {
*
* @return \Interop\Async\Awaitable<int> Resolves with the number of bytes sent on the channel.
*
* @throws \Amp\Concurrent\StatusError Thrown if the context has not been started.
* @throws \Amp\Concurrent\SynchronizationError If the context has not been started or the context
* @throws \Amp\Parallel\StatusError Thrown if the context has not been started.
* @throws \Amp\Parallel\SynchronizationError If the context has not been started or the context
* unexpectedly ends.
* @throws \Amp\Concurrent\ChannelException If sending on the channel fails.
* @throws \Amp\Parallel\ChannelException If sending on the channel fails.
* @throws \Error If an ExitStatus object is given.
* @throws \Amp\Concurrent\SerializationException If serializing the data fails.
* @throws \Amp\Parallel\SerializationException If serializing the data fails.
*/
public function send($data): Awaitable;
}

View File

@ -1,9 +1,9 @@
<?php declare(strict_types = 1);
namespace Amp\Concurrent\Sync;
namespace Amp\Parallel\Sync;
use Amp\Concurrent\{ ChannelException, SerializationException };
use Amp\Coroutine;
use Amp\Parallel\{ ChannelException, SerializationException };
use Amp\Stream\Stream;
use Interop\Async\Awaitable;

View File

@ -1,9 +1,9 @@
<?php declare(strict_types = 1);
namespace Amp\Concurrent\Sync;
namespace Amp\Parallel\Sync;
use Amp\Concurrent\MutexException;
use Amp\{ Coroutine, Pause };
use Amp\Parallel\MutexException;
use Interop\Async\Awaitable;
/**

View File

@ -1,8 +1,8 @@
<?php declare(strict_types = 1);
namespace Amp\Concurrent\Sync\Internal;
namespace Amp\Parallel\Sync\Internal;
use Amp\Concurrent\PanicError;
use Amp\Parallel\PanicError;
class ExitFailure implements ExitStatus {
/**

View File

@ -1,12 +1,12 @@
<?php declare(strict_types = 1);
namespace Amp\Concurrent\Sync\Internal;
namespace Amp\Parallel\Sync\Internal;
interface ExitStatus {
/**
* @return mixed Return value of the callable given to the execution context.
*
* @throws \Amp\Concurrent\PanicError If the context exited with an uncaught exception.
* @throws \Amp\Parallel\PanicError If the context exited with an uncaught exception.
*/
public function getResult();
}

View File

@ -1,6 +1,6 @@
<?php declare(strict_types = 1);
namespace Amp\Concurrent\Sync\Internal;
namespace Amp\Parallel\Sync\Internal;
class ExitSuccess implements ExitStatus {
/**

View File

@ -1,8 +1,8 @@
<?php declare(strict_types = 1);
namespace Amp\Concurrent\Sync;
namespace Amp\Parallel\Sync;
use Amp\Concurrent\LockAlreadyReleasedError;
use Amp\Parallel\LockAlreadyReleasedError;
/**
* A handle on an acquired lock from a synchronization object.

View File

@ -1,6 +1,6 @@
<?php declare(strict_types = 1);
namespace Amp\Concurrent\Sync;
namespace Amp\Parallel\Sync;
use Interop\Async\Awaitable;
@ -18,7 +18,7 @@ interface Mutex
*
* Acquires a lock on the mutex.
*
* @return \Interop\Async\Awaitable<\Amp\Concurrent\Sync\Lock> Resolves with a lock object when the acquire is
* @return \Interop\Async\Awaitable<\Amp\Parallel\Sync\Lock> Resolves with a lock object when the acquire is
* successful.
*/
public function acquire(): Awaitable;

View File

@ -1,6 +1,6 @@
<?php declare(strict_types = 1);
namespace Amp\Concurrent\Sync;
namespace Amp\Parallel\Sync;
/**
* A parcel object for sharing data across execution contexts.

View File

@ -1,9 +1,9 @@
<?php declare(strict_types = 1);
namespace Amp\Concurrent\Sync;
namespace Amp\Parallel\Sync;
use Amp\Concurrent\SemaphoreException;
use Amp\{ Coroutine, Pause };
use Amp\Parallel\SemaphoreException;
use Interop\Async\Awaitable;
/**

View File

@ -1,6 +1,6 @@
<?php declare(strict_types = 1);
namespace Amp\Concurrent\Sync;
namespace Amp\Parallel\Sync;
use Interop\Async\Awaitable;
@ -34,7 +34,7 @@ interface Semaphore extends \Countable {
* If there are one or more locks available, this function resolves immediately with a lock and the lock count is
* decreased. If no locks are available, the semaphore waits asynchronously for a lock to become available.
*
* @return \Interop\Async\Awaitable<\Amp\Concurrent\Sync\Lock> Resolves with a lock object when the acquire is
* @return \Interop\Async\Awaitable<\Amp\Parallel\Sync\Lock> Resolves with a lock object when the acquire is
* successful.
*/
public function acquire(): Awaitable;

View File

@ -1,9 +1,9 @@
<?php declare(strict_types = 1);
namespace Amp\Concurrent\Sync;
namespace Amp\Parallel\Sync;
use Amp\Concurrent\SharedMemoryException;
use Amp\Coroutine;
use Amp\Parallel\SharedMemoryException;
use Interop\Async\Awaitable;
/**
@ -183,7 +183,7 @@ class SharedMemoryParcel implements Parcel, \Serializable {
* @return \Generator
*/
private function doSynchronized(callable $callback): \Generator {
/** @var \Amp\Concurrent\Sync\Lock $lock */
/** @var \Amp\Parallel\Sync\Lock $lock */
$lock = yield $this->semaphore->acquire();
try {

View File

@ -1,6 +1,6 @@
<?php declare(strict_types = 1);
namespace Amp\Concurrent\Sync;
namespace Amp\Parallel\Sync;
use Interop\Async\Awaitable;

View File

@ -1,5 +1,5 @@
<?php declare(strict_types = 1);
namespace Amp\Concurrent;
namespace Amp\Parallel;
class SynchronizationError extends \Error {}

View File

@ -1,6 +1,6 @@
<?php declare(strict_types = 1);
namespace Amp\Concurrent;
namespace Amp\Parallel;
class TaskException extends \Exception {
/**

View File

@ -1,10 +1,9 @@
<?php declare(strict_types = 1);
namespace Amp\Concurrent\Threading\Internal;
namespace Amp\Parallel\Threading\Internal;
use Amp\Concurrent\Sync\Lock;
use Amp\Coroutine;
use Amp\Pause;
use Amp\{ Coroutine, Pause };
use Amp\Parallel\Sync\Lock;
use Interop\Async\Awaitable;
/**

View File

@ -1,9 +1,9 @@
<?php declare(strict_types = 1);
namespace Amp\Concurrent\Threading\Internal;
namespace Amp\Parallel\Threading\Internal;
use Amp\Concurrent\Sync\Lock;
use Amp\{ Coroutine, Pause };
use Amp\Parallel\Sync\Lock;
use Interop\Async\Awaitable;
/**

View File

@ -1,6 +1,6 @@
<?php declare(strict_types = 1);
namespace Amp\Concurrent\Threading\Internal;
namespace Amp\Parallel\Threading\Internal;
/**
* @internal

View File

@ -1,10 +1,10 @@
<?php declare(strict_types = 1);
namespace Amp\Concurrent\Threading\Internal;
namespace Amp\Parallel\Threading\Internal;
use Amp\Concurrent\{ChannelException, SerializationException};
use Amp\Concurrent\Sync\{Channel, ChannelledStream, Internal\ExitFailure, Internal\ExitSuccess};
use Amp\Coroutine;
use Amp\Parallel\{ ChannelException, SerializationException };
use Amp\Parallel\Sync\{ Channel, ChannelledStream, Internal\ExitFailure, Internal\ExitSuccess };
use Amp\Socket\Socket;
use Interop\Async\Awaitable;
@ -113,7 +113,7 @@ class Thread extends \Thread {
/**
* @coroutine
*
* @param \Amp\Concurrent\Sync\Channel $channel
* @param \Amp\Parallel\Sync\Channel $channel
*
* @return \Generator
*

View File

@ -1,8 +1,8 @@
<?php declare(strict_types = 1);
namespace Amp\Concurrent\Threading;
namespace Amp\Parallel\Threading;
use Amp\Concurrent\Sync\Mutex as SyncMutex;
use Amp\Parallel\Sync\Mutex as SyncMutex;
use Interop\Async\Awaitable;
/**
@ -12,7 +12,7 @@ use Interop\Async\Awaitable;
*/
class Mutex implements SyncMutex {
/**
* @var \Amp\Concurrent\Threading\Internal\Mutex
* @var \Amp\Parallel\Threading\Internal\Mutex
*/
private $mutex;

View File

@ -1,9 +1,9 @@
<?php declare(strict_types = 1);
namespace Amp\Concurrent\Threading;
namespace Amp\Parallel\Threading;
use Amp\Concurrent\Sync\Parcel as SyncParcel;
use Amp\Coroutine;
use Amp\Parallel\Sync\Parcel as SyncParcel;
use Interop\Async\Awaitable;
/**
@ -11,12 +11,12 @@ use Interop\Async\Awaitable;
*/
class Parcel implements SyncParcel {
/**
* @var \Amp\Concurrent\Threading\Mutex
* @var \Amp\Parallel\Threading\Mutex
*/
private $mutex;
/**
* @var \Amp\Concurrent\Threading\Internal\Storage
* @var \Amp\Parallel\Threading\Internal\Storage
*/
private $storage;
@ -69,7 +69,7 @@ class Parcel implements SyncParcel {
* @return \Generator
*/
private function doSynchronized(callable $callback): \Generator {
/** @var \Amp\Concurrent\Sync\Lock $lock */
/** @var \Amp\Parallel\Sync\Lock $lock */
$lock = yield $this->mutex->acquire();
try {

View File

@ -1,8 +1,8 @@
<?php declare(strict_types = 1);
namespace Amp\Concurrent\Threading;
namespace Amp\Parallel\Threading;
use Amp\Concurrent\Sync\Semaphore as SyncSemaphore;
use Amp\Parallel\Sync\Semaphore as SyncSemaphore;
use Interop\Async\Awaitable;
/**

View File

@ -1,10 +1,10 @@
<?php declare(strict_types = 1);
namespace Amp\Concurrent\Threading;
namespace Amp\Parallel\Threading;
use Amp\Concurrent\{ContextException, StatusError, SynchronizationError, Strand};
use Amp\Concurrent\Sync\{ChannelledStream, Internal\ExitStatus};
use Amp\Coroutine;
use Amp\Parallel\{ ContextException, StatusError, SynchronizationError, Strand };
use Amp\Parallel\Sync\{ ChannelledStream, Internal\ExitStatus };
use Amp\Socket\Socket;
use Interop\Async\Awaitable;
@ -22,7 +22,7 @@ class Thread implements Strand {
private $thread;
/**
* @var \Amp\Concurrent\Sync\Channel A channel for communicating with the thread.
* @var \Amp\Parallel\Sync\Channel A channel for communicating with the thread.
*/
private $channel;
@ -104,7 +104,7 @@ class Thread implements Strand {
/**
* Kills the thread if it is still running.
*
* @throws \Amp\Concurrent\ContextException
* @throws \Amp\Parallel\ContextException
*/
public function __destruct() {
if (\getmypid() === $this->oid) {
@ -124,8 +124,8 @@ class Thread implements Strand {
/**
* Spawns the thread and begins the thread's execution.
*
* @throws \Amp\Concurrent\StatusError If the thread has already been started.
* @throws \Amp\Concurrent\ContextException If starting the thread was unsuccessful.
* @throws \Amp\Parallel\StatusError If the thread has already been started.
* @throws \Amp\Parallel\ContextException If starting the thread was unsuccessful.
*/
public function start() {
if ($this->oid !== 0) {
@ -200,7 +200,7 @@ class Thread implements Strand {
*
* @return \Generator
*
* @throws \Amp\Concurrent\SynchronizationError If the thread does not send an exit status.
* @throws \Amp\Parallel\SynchronizationError If the thread does not send an exit status.
*/
private function doJoin(): \Generator {
try {

View File

@ -1,17 +1,17 @@
<?php declare(strict_types = 1);
namespace Amp\Concurrent\Worker;
namespace Amp\Parallel\Worker;
use Amp\Concurrent\{ StatusError, Strand, WorkerException} ;
use Amp\Concurrent\Worker\Internal\{ Job, TaskResult };
use Amp\{ Coroutine, Deferred };
use Amp\Parallel\{ StatusError, Strand, WorkerException} ;
use Amp\Parallel\Worker\Internal\{ Job, TaskResult };
use Interop\Async\Awaitable;
/**
* Base class for most common types of task workers.
*/
abstract class AbstractWorker implements Worker {
/** @var \Amp\Concurrent\Strand */
/** @var \Amp\Parallel\Strand */
private $context;
/** @var bool */
@ -24,7 +24,7 @@ abstract class AbstractWorker implements Worker {
private $when;
/**
* @param \Amp\Concurrent\Strand $strand
* @param \Amp\Parallel\Strand $strand
*/
public function __construct(Strand $strand) {
$this->context = $strand;
@ -97,12 +97,12 @@ abstract class AbstractWorker implements Worker {
/**
* @coroutine
*
* @param \Amp\Concurrent\Worker\Task $task
* @param \Amp\Parallel\Worker\Task $task
*
* @return \Generator
* @throws \Amp\Concurrent\StatusError
* @throws \Amp\Concurrent\TaskException
* @throws \Amp\Concurrent\WorkerException
* @throws \Amp\Parallel\StatusError
* @throws \Amp\Parallel\TaskException
* @throws \Amp\Parallel\WorkerException
*/
private function doEnqueue(Task $task): \Generator {
if (empty($this->jobQueue)) {

View File

@ -1,6 +1,6 @@
<?php declare(strict_types = 1);
namespace Amp\Concurrent\Worker;
namespace Amp\Parallel\Worker;
use Interop\Async\Loop;

View File

@ -1,10 +1,10 @@
<?php declare(strict_types = 1);
namespace Amp\Concurrent\Worker;
namespace Amp\Parallel\Worker;
use Amp;
use Amp\Concurrent\StatusError;
use Amp\Coroutine;
use Amp\Parallel\StatusError;
use Interop\Async\Awaitable;
/**
@ -62,7 +62,7 @@ class DefaultPool implements Pool {
* Defaults to `Pool::DEFAULT_MIN_SIZE`.
* @param int|null $maxSize The maximum number of workers the pool should spawn.
* Defaults to `Pool::DEFAULT_MAX_SIZE`.
* @param \Amp\Concurrent\Worker\WorkerFactory|null $factory A worker factory to be used to create
* @param \Amp\Parallel\Worker\WorkerFactory|null $factory A worker factory to be used to create
* new workers.
*
* @throws \Error
@ -174,8 +174,8 @@ class DefaultPool implements Pool {
*
* @return \Interop\Async\Awaitable<mixed> The return value of Task::run().
*
* @throws \Amp\Concurrent\StatusError If the pool has not been started.
* @throws \Amp\Concurrent\TaskException If the task throws an exception.
* @throws \Amp\Parallel\StatusError If the pool has not been started.
* @throws \Amp\Parallel\TaskException If the task throws an exception.
*/
public function enqueue(Task $task): Awaitable {
$worker = $this->get();
@ -189,7 +189,7 @@ class DefaultPool implements Pool {
*
* @return \Interop\Async\Awaitable<int[]> Array of exit status from all workers.
*
* @throws \Amp\Concurrent\StatusError If the pool has not been started.
* @throws \Amp\Parallel\StatusError If the pool has not been started.
*/
public function shutdown(): Awaitable {
if (!$this->isRunning()) {
@ -206,7 +206,7 @@ class DefaultPool implements Pool {
*
* @return \Generator
*
* @throws \Amp\Concurrent\StatusError If the pool has not been started.
* @throws \Amp\Parallel\StatusError If the pool has not been started.
*/
private function doShutdown(): \Generator {
$this->running = false;
@ -284,7 +284,7 @@ class DefaultPool implements Pool {
/**
* Pushes the worker back into the queue.
*
* @param \Amp\Concurrent\Worker\Worker $worker
* @param \Amp\Parallel\Worker\Worker $worker
*
* @throws \Error If the worker was not part of this queue.
*/

View File

@ -1,8 +1,8 @@
<?php declare(strict_types = 1);
namespace Amp\Concurrent\Worker;
namespace Amp\Parallel\Worker;
use Amp\Concurrent\{ Forking\Fork, Threading\Thread };
use Amp\Parallel\{ Forking\Fork, Threading\Thread };
/**
* The built-in worker factory type.

View File

@ -1,6 +1,6 @@
<?php declare(strict_types = 1);
namespace Amp\Concurrent\Worker;
namespace Amp\Parallel\Worker;
interface Environment extends \ArrayAccess, \Countable {
/**

View File

@ -1,14 +1,14 @@
<?php declare(strict_types = 1);
namespace Amp\Concurrent\Worker\Internal;
namespace Amp\Parallel\Worker\Internal;
use Amp\Concurrent\Worker\Task;
use Amp\Parallel\Worker\Task;
class Job {
/** @var string */
private $id;
/** @var \Amp\Concurrent\Worker\Task */
/** @var \Amp\Parallel\Worker\Task */
private $task;
public function __construct(Task $task) {

View File

@ -1,8 +1,8 @@
<?php declare(strict_types = 1);
namespace Amp\Concurrent\Worker\Internal;
namespace Amp\Parallel\Worker\Internal;
use Amp\Concurrent\Worker\{ Task, Worker };
use Amp\Parallel\Worker\{ Task, Worker };
use Interop\Async\Awaitable;
class PooledWorker implements Worker {
@ -12,12 +12,12 @@ class PooledWorker implements Worker {
private $push;
/**
* @var \Amp\Concurrent\Worker\Worker
* @var \Amp\Parallel\Worker\Worker
*/
private $worker;
/**
* @param \Amp\Concurrent\Worker\Worker $worker
* @param \Amp\Parallel\Worker\Worker $worker
* @param callable $push Callable to push the worker back into the queue.
*/
public function __construct(Worker $worker, callable $push) {

View File

@ -1,9 +1,9 @@
<?php declare(strict_types = 1);
namespace Amp\Concurrent\Worker\Internal;
namespace Amp\Parallel\Worker\Internal;
use Amp\Concurrent\TaskException;
use Amp\Failure;
use Amp\Parallel\TaskException;
use Interop\Async\Awaitable;
class TaskFailure implements TaskResult {

View File

@ -1,6 +1,6 @@
<?php declare(strict_types = 1);
namespace Amp\Concurrent\Worker\Internal;
namespace Amp\Parallel\Worker\Internal;
use Interop\Async\Awaitable;

View File

@ -1,19 +1,19 @@
<?php declare(strict_types = 1);
namespace Amp\Concurrent\Worker\Internal;
namespace Amp\Parallel\Worker\Internal;
use Amp\Concurrent\{ Sync\Channel, Worker\Environment };
use Amp\{ Coroutine, Failure, Success };
use Amp\Parallel\{ Sync\Channel, Worker\Environment };
use Interop\Async\Awaitable;
class TaskRunner {
/**
* @var \Amp\Concurrent\Sync\Channel
* @var \Amp\Parallel\Sync\Channel
*/
private $channel;
/**
* @var \Amp\Concurrent\Worker\Environment
* @var \Amp\Parallel\Worker\Environment
*/
private $environment;

View File

@ -1,6 +1,6 @@
<?php declare(strict_types = 1);
namespace Amp\Concurrent\Worker\Internal;
namespace Amp\Parallel\Worker\Internal;
use Amp\Success;
use Interop\Async\Awaitable;

View File

@ -1,6 +1,6 @@
<?php declare(strict_types = 1);
namespace Amp\Concurrent\Worker;
namespace Amp\Parallel\Worker;
/**
* An interface for worker pools.
@ -20,9 +20,9 @@ interface Pool extends Worker {
* Gets a worker from the pool. The worker is marked as busy and will only be reused if the pool runs out of
* idle workers. The worker will be automatically marked as idle once no references to the returned worker remain.
*
* @return \Amp\Concurrent\Worker\Worker
* @return \Amp\Parallel\Worker\Worker
*
* @throws \Amp\Concurrent\StatusError If the queue is not running.
* @throws \Amp\Parallel\StatusError If the queue is not running.
*/
public function get(): Worker;

View File

@ -1,6 +1,6 @@
<?php declare(strict_types = 1);
namespace Amp\Concurrent\Worker;
namespace Amp\Parallel\Worker;
/**
* A runnable unit of execution.
@ -11,7 +11,7 @@ interface Task {
*
* Does not have to be a coroutine, can also be a regular function returning a value.
*
* @param \Amp\Concurrent\Worker\Environment
* @param \Amp\Parallel\Worker\Environment
*
* @return mixed|\Interop\Async\Awaitable|\Generator
*/

View File

@ -1,6 +1,6 @@
<?php declare(strict_types = 1);
namespace Amp\Concurrent\Worker;
namespace Amp\Parallel\Worker;
use Interop\Async\Awaitable;

View File

@ -1,6 +1,6 @@
<?php declare(strict_types = 1);
namespace Amp\Concurrent\Worker;
namespace Amp\Parallel\Worker;
/**
* Interface for factories used to create new workers.

View File

@ -1,9 +1,9 @@
<?php declare(strict_types = 1);
namespace Amp\Concurrent\Worker;
namespace Amp\Parallel\Worker;
use Amp\Concurrent\Forking\Fork;
use Amp\Concurrent\Worker\Internal\TaskRunner;
use Amp\Parallel\Forking\Fork;
use Amp\Parallel\Worker\Internal\TaskRunner;
use Interop\Async\Awaitable;
/**

View File

@ -1,8 +1,8 @@
<?php declare(strict_types = 1);
namespace Amp\Concurrent\Worker;
namespace Amp\Parallel\Worker;
use Amp\Concurrent\Process\ChannelledProcess;
use Amp\Parallel\Process\ChannelledProcess;
/**
* A worker thread that executes task objects.

View File

@ -1,9 +1,9 @@
<?php declare(strict_types = 1);
namespace Amp\Concurrent\Worker;
namespace Amp\Parallel\Worker;
use Amp\Concurrent\Threading\Thread;
use Amp\Concurrent\Worker\Internal\TaskRunner;
use Amp\Parallel\Threading\Thread;
use Amp\Parallel\Worker\Internal\TaskRunner;
use Interop\Async\Awaitable;
/**

View File

@ -1,15 +1,15 @@
<?php declare(strict_types = 1);
namespace Amp\Concurrent\Worker;
namespace Amp\Parallel\Worker;
use Interop\Async\Awaitable;
/**
* Returns the global worker pool for the current context.
*
* @param \Amp\Concurrent\Worker\Pool|null $pool A worker pool instance.
* @param \Amp\Parallel\Worker\Pool|null $pool A worker pool instance.
*
* @return \Amp\Concurrent\Worker\Pool The global worker pool instance.
* @return \Amp\Parallel\Worker\Pool The global worker pool instance.
*/
function pool(Pool $pool = null): Pool {
static $instance;
@ -30,7 +30,7 @@ function pool(Pool $pool = null): Pool {
/**
* Enqueues a task to be executed by the global worker pool.
*
* @param \Amp\Concurrent\Worker\Task $task The task to enqueue.
* @param \Amp\Parallel\Worker\Task $task The task to enqueue.
*
* @return \Interop\Async\Awaitable<mixed>
*/
@ -41,7 +41,7 @@ function enqueue(Task $task): Awaitable {
/**
* Creates a worker using the global worker factory.
*
* @return \Amp\Concurrent\Worker\Worker
* @return \Amp\Parallel\Worker\Worker
*/
function create(): Worker {
$worker = factory()->create();
@ -52,9 +52,9 @@ function create(): Worker {
/**
* Gets or sets the global worker factory.
*
* @param \Amp\Concurrent\Worker\WorkerFactory|null $factory
* @param \Amp\Parallel\Worker\WorkerFactory|null $factory
*
* @return \Amp\Concurrent\Worker\WorkerFactory
* @return \Amp\Parallel\Worker\WorkerFactory
*/
function factory(WorkerFactory $factory = null): WorkerFactory {
static $instance;
@ -71,7 +71,7 @@ function factory(WorkerFactory $factory = null): WorkerFactory {
/**
* Gets a worker from the global worker pool.
*
* @return \Amp\Concurrent\Worker\Worker
* @return \Amp\Parallel\Worker\Worker
*/
function get(): Worker {
return pool()->get();

View File

@ -1,6 +1,6 @@
<?php declare(strict_types = 1);
namespace Amp\Concurrent;
namespace Amp\Parallel;
class WorkerException extends \Exception {
/**

View File

@ -1,14 +1,14 @@
<?php declare(strict_types = 1);
namespace Amp\Concurrent\Test;
namespace Amp\Parallel\Test;
use Amp\Concurrent\Sync\Internal\ExitSuccess;
use Amp\Parallel\Sync\Internal\ExitSuccess;
abstract class AbstractContextTest extends TestCase {
/**
* @param callable $function
*
* @return \Amp\Concurrent\Context
* @return \Amp\Parallel\Context
*/
abstract public function createContext(callable $function);
@ -43,7 +43,7 @@ abstract class AbstractContextTest extends TestCase {
}
/**
* @expectedException \Amp\Concurrent\StatusError
* @expectedException \Amp\Parallel\StatusError
*/
public function testStartWhileRunningThrowsError() {
$context = $this->createContext(function () {
@ -55,7 +55,7 @@ abstract class AbstractContextTest extends TestCase {
}
/**
* @expectedException \Amp\Concurrent\StatusError
* @expectedException \Amp\Parallel\StatusError
*/
public function testStartMultipleTimesThrowsError() {
$this->assertRunTimeGreaterThan(function () {
@ -74,7 +74,7 @@ abstract class AbstractContextTest extends TestCase {
}
/**
* @expectedException \Amp\Concurrent\PanicError
* @expectedException \Amp\Parallel\PanicError
*/
public function testExceptionInContextPanics() {
\Amp\execute(function () {
@ -88,7 +88,7 @@ abstract class AbstractContextTest extends TestCase {
}
/**
* @expectedException \Amp\Concurrent\PanicError
* @expectedException \Amp\Parallel\PanicError
*/
public function testReturnUnserializableDataPanics() {
\Amp\execute(function () {
@ -116,7 +116,7 @@ abstract class AbstractContextTest extends TestCase {
}
/**
* @expectedException \Amp\Concurrent\StatusError
* @expectedException \Amp\Parallel\StatusError
*/
public function testJoinWithoutStartThrowsError() {
\Amp\execute(function () {
@ -158,7 +158,7 @@ abstract class AbstractContextTest extends TestCase {
/**
* @depends testSendAndReceive
* @expectedException \Amp\Concurrent\SynchronizationError
* @expectedException \Amp\Parallel\SynchronizationError
*/
public function testJoinWhenContextSendingData() {
\Amp\execute(function () {
@ -174,7 +174,7 @@ abstract class AbstractContextTest extends TestCase {
/**
* @depends testSendAndReceive
* @expectedException \Amp\Concurrent\StatusError
* @expectedException \Amp\Parallel\StatusError
*/
public function testReceiveBeforeContextHasStarted() {
\Amp\execute(function () {
@ -189,7 +189,7 @@ abstract class AbstractContextTest extends TestCase {
/**
* @depends testSendAndReceive
* @expectedException \Amp\Concurrent\StatusError
* @expectedException \Amp\Parallel\StatusError
*/
public function testSendBeforeContextHasStarted() {
\Amp\execute(function () {
@ -204,7 +204,7 @@ abstract class AbstractContextTest extends TestCase {
/**
* @depends testSendAndReceive
* @expectedException \Amp\Concurrent\SynchronizationError
* @expectedException \Amp\Parallel\SynchronizationError
*/
public function testReceiveWhenContextHasReturned() {
\Amp\execute(function () {

View File

@ -1,9 +1,9 @@
<?php declare(strict_types = 1);
namespace Amp\Concurrent\Test\Forking;
namespace Amp\Parallel\Test\Forking;
use Amp\Concurrent\Forking\Fork;
use Amp\Concurrent\Test\AbstractContextTest;
use Amp\Parallel\Forking\Fork;
use Amp\Parallel\Test\AbstractContextTest;
/**
* @group forking

View File

@ -1,6 +1,6 @@
<?php declare(strict_types = 1);
namespace Amp\Concurrent\Test\Stub;
namespace Amp\Parallel\Test\Stub;
class CallbackStub {
public function __invoke() {}

View File

@ -1,12 +1,12 @@
<?php declare(strict_types = 1);
namespace Amp\Concurrent\Test\Sync;
namespace Amp\Parallel\Test\Sync;
use Amp\Concurrent\Test\TestCase;
use Amp\Parallel\Test\TestCase;
abstract class AbstractParcelTest extends TestCase {
/**
* @return \Amp\Concurrent\Sync\Parcel
* @return \Amp\Parallel\Sync\Parcel
*/
abstract protected function createParcel($value);

View File

@ -1,21 +1,21 @@
<?php declare(strict_types = 1);
namespace Amp\Concurrent\Test\Sync;
namespace Amp\Parallel\Test\Sync;
use Amp\Concurrent\Sync\Lock;
use Amp\Concurrent\Test\TestCase;
use Amp\Parallel\Sync\Lock;
use Amp\Parallel\Test\TestCase;
use Amp\Pause;
abstract class AbstractSemaphoreTest extends TestCase {
/**
* @var \Amp\Concurrent\Sync\Semaphore
* @var \Amp\Parallel\Sync\Semaphore
*/
protected $semaphore;
/**
* @param int $locks Number of locks in the semaphore.
*
* @return \Amp\Concurrent\Sync\Semaphore
* @return \Amp\Parallel\Sync\Semaphore
*/
abstract public function createSemaphore(int $locks);

View File

@ -1,11 +1,11 @@
<?php declare(strict_types = 1);
namespace Amp\Concurrent\Test\Sync;
namespace Amp\Parallel\Test\Sync;
use Amp\Concurrent\Sync\ChannelledStream;
use Amp\Parallel\Sync\ChannelledStream;
use Amp\Stream\Stream;
use Amp\Stream\ClosedException;
use Amp\Concurrent\Test\TestCase;
use Amp\Parallel\Test\TestCase;
use Amp\Success;
class ChannelledStreamTest extends TestCase {
@ -71,7 +71,7 @@ class ChannelledStreamTest extends TestCase {
/**
* @depends testSendReceive
* @expectedException \Amp\Concurrent\ChannelException
* @expectedException \Amp\Parallel\ChannelException
*/
public function testInvalidDataReceived() {
\Amp\execute(function () {
@ -88,7 +88,7 @@ class ChannelledStreamTest extends TestCase {
/**
* @depends testSendReceive
* @expectedException \Amp\Concurrent\ChannelException
* @expectedException \Amp\Parallel\ChannelException
*/
public function testSendUnserializableData() {
\Amp\execute(function () {
@ -105,7 +105,7 @@ class ChannelledStreamTest extends TestCase {
/**
* @depends testSendReceive
* @expectedException \Amp\Concurrent\ChannelException
* @expectedException \Amp\Parallel\ChannelException
*/
public function testSendAfterClose() {
\Amp\execute(function () {
@ -124,7 +124,7 @@ class ChannelledStreamTest extends TestCase {
/**
* @depends testSendReceive
* @expectedException \Amp\Concurrent\ChannelException
* @expectedException \Amp\Parallel\ChannelException
*/
public function testReceiveAfterClose() {
\Amp\execute(function () {

View File

@ -1,9 +1,9 @@
<?php declare(strict_types = 1);
namespace Amp\Concurrent\Test\Sync;
namespace Amp\Parallel\Test\Sync;
use Amp\Concurrent\Sync\FileMutex;
use Amp\Concurrent\Test\TestCase;
use Amp\Parallel\Sync\FileMutex;
use Amp\Parallel\Test\TestCase;
class FileMutexTest extends TestCase {
public function testAcquire() {

View File

@ -1,9 +1,9 @@
<?php declare(strict_types = 1);
namespace Amp\Concurrent\Test\Sync;
namespace Amp\Parallel\Test\Sync;
use Amp\Concurrent\Sync\Lock;
use Amp\Concurrent\Test\TestCase;
use Amp\Parallel\Sync\Lock;
use Amp\Parallel\Test\TestCase;
class LockTest extends TestCase {
public function testIsReleased() {
@ -19,7 +19,7 @@ class LockTest extends TestCase {
}
/**
* @expectedException \Amp\Concurrent\LockAlreadyReleasedError
* @expectedException \Amp\Parallel\LockAlreadyReleasedError
*/
public function testThrowsOnMultiRelease() {
$lock = new Lock($this->createCallback(1));

View File

@ -1,9 +1,9 @@
<?php declare(strict_types = 1);
namespace Amp\Concurrent\Test\Sync;
namespace Amp\Parallel\Test\Sync;
use Amp\Concurrent\Forking\Fork;
use Amp\Concurrent\Sync\{PosixSemaphore, Semaphore};
use Amp\Parallel\Forking\Fork;
use Amp\Parallel\Sync\{PosixSemaphore, Semaphore};
/**
* @group posix
@ -13,7 +13,7 @@ class PosixSemaphoreTest extends AbstractSemaphoreTest {
/**
* @param $locks
*
* @return \Amp\Concurrent\Sync\PosixSemaphore
* @return \Amp\Parallel\Sync\PosixSemaphore
*/
public function createSemaphore(int $locks) {
return new PosixSemaphore($locks);

View File

@ -1,8 +1,8 @@
<?php declare(strict_types = 1);
namespace Amp\Concurrent\Test\Sync;
namespace Amp\Parallel\Test\Sync;
use Amp\Concurrent\Sync\SharedMemoryParcel;
use Amp\Parallel\Sync\SharedMemoryParcel;
/**
* @requires extension shmop
@ -35,7 +35,7 @@ class SharedMemoryParcelTest extends AbstractParcelTest {
}
/**
* @expectedException \Amp\Concurrent\SharedMemoryException
* @expectedException \Amp\Parallel\SharedMemoryException
*/
public function testUnwrapThrowsErrorIfFreed() {
$object = new SharedMemoryParcel(new \stdClass());

View File

@ -1,8 +1,8 @@
<?php declare(strict_types = 1);
namespace Amp\Concurrent\Test;
namespace Amp\Parallel\Test;
use Amp\Concurrent\Test\Stub\CallbackStub;
use Amp\Parallel\Test\Stub\CallbackStub;
/**
* Abstract test class with methods for creating callbacks and asserting runtimes.

View File

@ -1,9 +1,9 @@
<?php declare(strict_types = 1);
namespace Amp\Concurrent\Test\Threading;
namespace Amp\Parallel\Test\Threading;
use Amp\Concurrent\Threading\Mutex;
use Amp\Concurrent\Test\TestCase;
use Amp\Parallel\Threading\Mutex;
use Amp\Parallel\Test\TestCase;
/**
* @group threading

View File

@ -1,9 +1,9 @@
<?php declare(strict_types = 1);
namespace Amp\Concurrent\Test\Threading;
namespace Amp\Parallel\Test\Threading;
use Amp\Concurrent\Threading\Parcel;
use Amp\Concurrent\Test\Sync\AbstractParcelTest;
use Amp\Parallel\Threading\Parcel;
use Amp\Parallel\Test\Sync\AbstractParcelTest;
/**
* @requires extension pthreads

View File

@ -1,10 +1,10 @@
<?php declare(strict_types = 1);
namespace Amp\Concurrent\Test\Threading;
namespace Amp\Parallel\Test\Threading;
use Amp\Concurrent\Sync\Semaphore as SyncSemaphore;
use Amp\Concurrent\Threading\{Semaphore, Thread};
use Amp\Concurrent\Test\Sync\AbstractSemaphoreTest;
use Amp\Parallel\Sync\Semaphore as SyncSemaphore;
use Amp\Parallel\Threading\{Semaphore, Thread};
use Amp\Parallel\Test\Sync\AbstractSemaphoreTest;
/**
* @group threading

View File

@ -1,9 +1,9 @@
<?php declare(strict_types = 1);
namespace Amp\Concurrent\Test\Threading;
namespace Amp\Parallel\Test\Threading;
use Amp\Concurrent\Threading\Thread;
use Amp\Concurrent\Test\AbstractContextTest;
use Amp\Parallel\Threading\Thread;
use Amp\Parallel\Test\AbstractContextTest;
/**
* @group threading

View File

@ -1,15 +1,15 @@
<?php declare(strict_types = 1);
namespace Amp\Concurrent\Test\Worker;
namespace Amp\Parallel\Test\Worker;
use Amp\Concurrent\Test\TestCase;
use Amp\Parallel\Test\TestCase;
abstract class AbstractPoolTest extends TestCase {
/**
* @param int $min
* @param int $max
*
* @return \Amp\Concurrent\Worker\Pool
* @return \Amp\Parallel\Worker\Pool
*/
abstract protected function createPool($min = null, $max = null);

View File

@ -1,12 +1,12 @@
<?php declare(strict_types = 1);
namespace Amp\Concurrent\Test\Worker;
namespace Amp\Parallel\Test\Worker;
use Amp\Concurrent\Test\TestCase;
use Amp\Parallel\Test\TestCase;
abstract class AbstractWorkerTest extends TestCase {
/**
* @return \Amp\Concurrent\Worker\Worker
* @return \Amp\Parallel\Worker\Worker
*/
abstract protected function createWorker();

View File

@ -1,8 +1,8 @@
<?php declare(strict_types = 1);
namespace Amp\Concurrent\Test\Worker;
namespace Amp\Parallel\Test\Worker;
use Amp\Concurrent\Worker\{ DefaultPool, WorkerFactory, WorkerFork };
use Amp\Parallel\Worker\{ DefaultPool, WorkerFactory, WorkerFork };
/**
* @group forking

View File

@ -1,10 +1,10 @@
<?php declare(strict_types = 1);
namespace Amp\Concurrent\Test\Worker;
namespace Amp\Parallel\Test\Worker;
use Amp\Concurrent\Worker;
use Amp\Concurrent\Worker\{ Environment, Pool, Task, WorkerFactory };
use Amp\Concurrent\Test\TestCase;
use Amp\Parallel\Worker;
use Amp\Parallel\Worker\{ Environment, Pool, Task, WorkerFactory };
use Amp\Parallel\Test\TestCase;
use Amp\Success;
use Interop\Async\Awaitable;

View File

@ -1,8 +1,8 @@
<?php declare(strict_types = 1);
namespace Amp\Concurrent\Test\Worker;
namespace Amp\Parallel\Test\Worker;
use Amp\Concurrent\Worker\{ DefaultPool, WorkerFactory, WorkerProcess };
use Amp\Parallel\Worker\{ DefaultPool, WorkerFactory, WorkerProcess };
/**
* @group process

View File

@ -1,8 +1,8 @@
<?php declare(strict_types = 1);
namespace Amp\Concurrent\Test\Worker;
namespace Amp\Parallel\Test\Worker;
use Amp\Concurrent\Worker\{ Environment, Task };
use Amp\Parallel\Worker\{ Environment, Task };
class TestTask implements Task {
private $returnValue;

View File

@ -1,8 +1,8 @@
<?php declare(strict_types = 1);
namespace Amp\Concurrent\Test\Worker;
namespace Amp\Parallel\Test\Worker;
use Amp\Concurrent\Worker\{ DefaultPool, WorkerFactory, WorkerThread };
use Amp\Parallel\Worker\{ DefaultPool, WorkerFactory, WorkerThread };
/**
* @group threading

View File

@ -1,8 +1,8 @@
<?php declare(strict_types = 1);
namespace Amp\Concurrent\Test\Worker;
namespace Amp\Parallel\Test\Worker;
use Amp\Concurrent\Worker\WorkerFork;
use Amp\Parallel\Worker\WorkerFork;
/**
* @group forking

View File

@ -1,8 +1,8 @@
<?php declare(strict_types = 1);
namespace Amp\Concurrent\Test\Worker;
namespace Amp\Parallel\Test\Worker;
use Amp\Concurrent\Worker\WorkerProcess;
use Amp\Parallel\Worker\WorkerProcess;
class WorkerProcessTest extends AbstractWorkerTest {
protected function createWorker() {

View File

@ -1,8 +1,8 @@
<?php declare(strict_types = 1);
namespace Amp\Concurrent\Test\Worker;
namespace Amp\Parallel\Test\Worker;
use Amp\Concurrent\Worker\WorkerThread;
use Amp\Parallel\Worker\WorkerThread;
/**
* @group threading