mirror of
https://github.com/amphp/parallel.git
synced 2025-02-21 13:22:44 +01:00
Property docblock cleanup
This commit is contained in:
parent
740239c0f4
commit
8126b8e3f2
@ -21,34 +21,22 @@ use Interop\Async\Awaitable;
|
||||
* Implements a UNIX-compatible context using forked processes.
|
||||
*/
|
||||
class Fork implements Process, Strand {
|
||||
/**
|
||||
* @var \Amp\Parallel\Sync\Channel A channel for communicating with the child.
|
||||
*/
|
||||
/** @var \Amp\Parallel\Sync\Channel A channel for communicating with the child. */
|
||||
private $channel;
|
||||
|
||||
/**
|
||||
* @var \Amp\Socket\Socket
|
||||
*/
|
||||
/** @var \Amp\Socket\Socket */
|
||||
private $pipe;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
/** @var int */
|
||||
private $pid = 0;
|
||||
|
||||
/**
|
||||
* @var callable
|
||||
*/
|
||||
/** @var callable */
|
||||
private $function;
|
||||
|
||||
/**
|
||||
* @var mixed[]
|
||||
*/
|
||||
/** @var mixed[] */
|
||||
private $args;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
/** @var int */
|
||||
private $oid = 0;
|
||||
|
||||
/**
|
||||
|
@ -3,9 +3,7 @@
|
||||
namespace Amp\Parallel;
|
||||
|
||||
class PanicError extends \Error {
|
||||
/**
|
||||
* @var string Stack trace of the panic.
|
||||
*/
|
||||
/** @var string Stack trace of the panic. */
|
||||
private $trace;
|
||||
|
||||
/**
|
||||
|
@ -7,14 +7,10 @@ use Amp\Parallel\Sync\{ ChannelledStream, Internal\ExitStatus };
|
||||
use Interop\Async\Awaitable;
|
||||
|
||||
class ChannelledProcess implements ProcessContext, Strand {
|
||||
/**
|
||||
* @var \Amp\Parallel\Process\Process
|
||||
*/
|
||||
/** @var \Amp\Parallel\Process\Process */
|
||||
private $process;
|
||||
|
||||
/**
|
||||
* @var \Amp\Parallel\Sync\Channel
|
||||
*/
|
||||
/** @var \Amp\Parallel\Sync\Channel */
|
||||
private $channel;
|
||||
|
||||
/**
|
||||
|
@ -9,64 +9,40 @@ use Amp\Stream\Stream;
|
||||
use Interop\Async\{ Awaitable, Loop };
|
||||
|
||||
class Process implements ProcessContext {
|
||||
/**
|
||||
* @var resource|null
|
||||
*/
|
||||
/** @var resource|null */
|
||||
private $process;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
/** @var string */
|
||||
private $command;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
/** @var string */
|
||||
private $cwd = '';
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
/** @var array */
|
||||
private $env = [];
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
/** @var array */
|
||||
private $options;
|
||||
|
||||
/**
|
||||
* @var \Amp\Stream\Stream|null
|
||||
*/
|
||||
/** @var \Amp\Stream\Stream|null */
|
||||
private $stdin;
|
||||
|
||||
/**
|
||||
* @var \Amp\Stream\Stream|null
|
||||
*/
|
||||
/** @var \Amp\Stream\Stream|null */
|
||||
private $stdout;
|
||||
|
||||
/**
|
||||
* @var \Amp\Stream\Stream|null
|
||||
*/
|
||||
/** @var \Amp\Stream\Stream|null */
|
||||
private $stderr;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
/** @var int */
|
||||
private $pid = 0;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
/** @var int */
|
||||
private $oid = 0;
|
||||
|
||||
/**
|
||||
* @var \Amp\Deferred|null
|
||||
*/
|
||||
/** @var \Amp\Deferred|null */
|
||||
private $deferred;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
/** @var string */
|
||||
private $watcher;
|
||||
|
||||
/**
|
||||
|
@ -15,19 +15,13 @@ use Interop\Async\Awaitable;
|
||||
class ChannelledStream implements Channel {
|
||||
const HEADER_LENGTH = 5;
|
||||
|
||||
/**
|
||||
* @var \Amp\Stream\Stream
|
||||
*/
|
||||
/** @var \Amp\Stream\Stream */
|
||||
private $read;
|
||||
|
||||
/**
|
||||
* @var \Amp\Stream\Stream
|
||||
*/
|
||||
/** @var \Amp\Stream\Stream */
|
||||
private $write;
|
||||
|
||||
/**
|
||||
* @var \Closure
|
||||
*/
|
||||
/** @var \Closure */
|
||||
private $errorHandler;
|
||||
|
||||
/**
|
||||
|
@ -24,9 +24,7 @@ use Interop\Async\Awaitable;
|
||||
class FileMutex implements Mutex {
|
||||
const LATENCY_TIMEOUT = 10;
|
||||
|
||||
/**
|
||||
* @var string The full path to the lock file.
|
||||
*/
|
||||
/** @var string The full path to the lock file. */
|
||||
private $fileName;
|
||||
|
||||
/**
|
||||
|
@ -5,24 +5,16 @@ namespace Amp\Parallel\Sync\Internal;
|
||||
use Amp\Parallel\PanicError;
|
||||
|
||||
class ExitFailure implements ExitStatus {
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
/** @var string */
|
||||
private $type;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
/** @var string */
|
||||
private $message;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
/** @var int */
|
||||
private $code;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
/** @var array */
|
||||
private $trace;
|
||||
|
||||
public function __construct(\Throwable $exception) {
|
||||
|
@ -3,9 +3,7 @@
|
||||
namespace Amp\Parallel\Sync\Internal;
|
||||
|
||||
class ExitSuccess implements ExitStatus {
|
||||
/**
|
||||
* @var mixed
|
||||
*/
|
||||
/** @var mixed */
|
||||
private $result;
|
||||
|
||||
public function __construct($result) {
|
||||
|
@ -12,14 +12,10 @@ use Amp\Parallel\LockAlreadyReleasedError;
|
||||
* released.
|
||||
*/
|
||||
class Lock {
|
||||
/**
|
||||
* @var callable The function to be called on release.
|
||||
*/
|
||||
/** @var callable The function to be called on release. */
|
||||
private $releaser;
|
||||
|
||||
/**
|
||||
* @var bool Indicates if the lock has been released.
|
||||
*/
|
||||
/** @var bool Indicates if the lock has been released. */
|
||||
private $released = false;
|
||||
|
||||
/**
|
||||
|
@ -17,19 +17,13 @@ use Interop\Async\Awaitable;
|
||||
class PosixSemaphore implements Semaphore, \Serializable {
|
||||
const LATENCY_TIMEOUT = 10;
|
||||
|
||||
/**
|
||||
* @var int The semaphore key.
|
||||
*/
|
||||
/** @var int The semaphore key. */
|
||||
private $key;
|
||||
|
||||
/**
|
||||
* @var int The number of total locks.
|
||||
*/
|
||||
/** @var int The number of total locks. */
|
||||
private $maxLocks;
|
||||
|
||||
/**
|
||||
* @var resource A message queue of available locks.
|
||||
*/
|
||||
/** @var resource A message queue of available locks. */
|
||||
private $queue;
|
||||
|
||||
/**
|
||||
|
@ -29,9 +29,7 @@ use Interop\Async\Awaitable;
|
||||
* @see https://msdn.microsoft.com/en-us/library/ms810613.aspx How shared memory works on Windows.
|
||||
*/
|
||||
class SharedMemoryParcel implements Parcel, \Serializable {
|
||||
/**
|
||||
* @var int The byte offset to the start of the object data in memory.
|
||||
*/
|
||||
/** @var int The byte offset to the start of the object data in memory. */
|
||||
const MEM_DATA_OFFSET = 7;
|
||||
|
||||
// A list of valid states the object can be in.
|
||||
@ -40,19 +38,13 @@ class SharedMemoryParcel implements Parcel, \Serializable {
|
||||
const STATE_MOVED = 2;
|
||||
const STATE_FREED = 3;
|
||||
|
||||
/**
|
||||
* @var int The shared memory segment key.
|
||||
*/
|
||||
/** @var int The shared memory segment key. */
|
||||
private $key;
|
||||
|
||||
/**
|
||||
* @var PosixSemaphore A semaphore for synchronizing on the parcel.
|
||||
*/
|
||||
/** @var PosixSemaphore A semaphore for synchronizing on the parcel. */
|
||||
private $semaphore;
|
||||
|
||||
/**
|
||||
* @var int An open handle to the shared memory segment.
|
||||
*/
|
||||
/** @var int An open handle to the shared memory segment. */
|
||||
private $handle;
|
||||
|
||||
/**
|
||||
|
@ -3,9 +3,7 @@
|
||||
namespace Amp\Parallel;
|
||||
|
||||
class TaskException extends \Exception {
|
||||
/**
|
||||
* @var string Stack trace of the panic.
|
||||
*/
|
||||
/** @var string Stack trace of the panic. */
|
||||
private $trace;
|
||||
|
||||
/**
|
||||
|
@ -12,9 +12,7 @@ use Interop\Async\Awaitable;
|
||||
class Mutex extends \Threaded {
|
||||
const LATENCY_TIMEOUT = 10;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
/** @var bool */
|
||||
private $lock = true;
|
||||
|
||||
/**
|
||||
|
@ -14,9 +14,7 @@ use Interop\Async\Awaitable;
|
||||
class Semaphore extends \Threaded {
|
||||
const LATENCY_TIMEOUT = 10;
|
||||
|
||||
/**
|
||||
* @var int The number of available locks.
|
||||
*/
|
||||
/** @var int The number of available locks. */
|
||||
private $locks;
|
||||
|
||||
/**
|
||||
|
@ -6,9 +6,7 @@ namespace Amp\Parallel\Threading\Internal;
|
||||
* @internal
|
||||
*/
|
||||
class Storage extends \Threaded {
|
||||
/**
|
||||
* @var mixed
|
||||
*/
|
||||
/** @var mixed */
|
||||
private $value;
|
||||
|
||||
/**
|
||||
|
@ -16,24 +16,16 @@ use Interop\Async\Awaitable;
|
||||
class Thread extends \Thread {
|
||||
const KILL_CHECK_FREQUENCY = 250;
|
||||
|
||||
/**
|
||||
* @var callable The function to execute in the thread.
|
||||
*/
|
||||
/** @var callable The function to execute in the thread. */
|
||||
private $function;
|
||||
|
||||
/**
|
||||
* @var mixed[] Arguments to pass to the function.
|
||||
*/
|
||||
/** @var mixed[] Arguments to pass to the function. */
|
||||
private $args;
|
||||
|
||||
/**
|
||||
* @var resource
|
||||
*/
|
||||
/** @var resource */
|
||||
private $socket;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
/** @var bool */
|
||||
private $killed = false;
|
||||
|
||||
/**
|
||||
|
@ -11,9 +11,7 @@ use Interop\Async\Awaitable;
|
||||
* Compatible with POSIX systems and Microsoft Windows.
|
||||
*/
|
||||
class Mutex implements SyncMutex {
|
||||
/**
|
||||
* @var \Amp\Parallel\Threading\Internal\Mutex
|
||||
*/
|
||||
/** @var \Amp\Parallel\Threading\Internal\Mutex */
|
||||
private $mutex;
|
||||
|
||||
/**
|
||||
|
@ -10,14 +10,10 @@ use Interop\Async\Awaitable;
|
||||
* A thread-safe container that shares a value between multiple threads.
|
||||
*/
|
||||
class Parcel implements SyncParcel {
|
||||
/**
|
||||
* @var \Amp\Parallel\Threading\Mutex
|
||||
*/
|
||||
/** @var \Amp\Parallel\Threading\Mutex */
|
||||
private $mutex;
|
||||
|
||||
/**
|
||||
* @var \Amp\Parallel\Threading\Internal\Storage
|
||||
*/
|
||||
/** @var \Amp\Parallel\Threading\Internal\Storage */
|
||||
private $storage;
|
||||
|
||||
/**
|
||||
|
@ -14,14 +14,10 @@ use Interop\Async\Awaitable;
|
||||
* small delay. However, the small delay will not block the thread.
|
||||
*/
|
||||
class Semaphore implements SyncSemaphore {
|
||||
/**
|
||||
* @var Internal\Semaphore
|
||||
*/
|
||||
/** @var Internal\Semaphore */
|
||||
private $semaphore;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
/** @var int */
|
||||
private $maxLocks;
|
||||
|
||||
/**
|
||||
|
@ -16,39 +16,25 @@ use Interop\Async\Awaitable;
|
||||
* itself.
|
||||
*/
|
||||
class Thread implements Strand {
|
||||
/**
|
||||
* @var Internal\Thread An internal thread instance.
|
||||
*/
|
||||
/** @var Internal\Thread An internal thread instance. */
|
||||
private $thread;
|
||||
|
||||
/**
|
||||
* @var \Amp\Parallel\Sync\Channel A channel for communicating with the thread.
|
||||
*/
|
||||
/** @var \Amp\Parallel\Sync\Channel A channel for communicating with the thread. */
|
||||
private $channel;
|
||||
|
||||
/**
|
||||
* @var \Amp\Socket\Socket
|
||||
*/
|
||||
/** @var \Amp\Socket\Socket */
|
||||
private $pipe;
|
||||
|
||||
/**
|
||||
* @var resource
|
||||
*/
|
||||
/** @var resource */
|
||||
private $socket;
|
||||
|
||||
/**
|
||||
* @var callable
|
||||
*/
|
||||
/** @var callable */
|
||||
private $function;
|
||||
|
||||
/**
|
||||
* @var mixed[]
|
||||
*/
|
||||
/** @var mixed[] */
|
||||
private $args;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
/** @var int */
|
||||
private $oid = 0;
|
||||
|
||||
/**
|
||||
|
@ -5,29 +5,19 @@ namespace Amp\Parallel\Worker;
|
||||
use Interop\Async\Loop;
|
||||
|
||||
class BasicEnvironment implements Environment {
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
/** @var array */
|
||||
private $data = [];
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
/** @var array */
|
||||
private $ttl = [];
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
/** @var array */
|
||||
private $expire = [];
|
||||
|
||||
/**
|
||||
* @var \SplPriorityQueue
|
||||
*/
|
||||
/** @var \SplPriorityQueue */
|
||||
private $queue;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
/** @var string */
|
||||
private $timer;
|
||||
|
||||
public function __construct() {
|
||||
|
@ -15,44 +15,28 @@ use Interop\Async\Awaitable;
|
||||
* are completed as soon as possible and workers are used efficiently.
|
||||
*/
|
||||
class DefaultPool implements Pool {
|
||||
/**
|
||||
* @var bool Indicates if the pool is currently running.
|
||||
*/
|
||||
/** @var bool Indicates if the pool is currently running. */
|
||||
private $running = false;
|
||||
|
||||
/**
|
||||
* @var int The minimum number of workers the pool should spawn.
|
||||
*/
|
||||
/** @var int The minimum number of workers the pool should spawn. */
|
||||
private $minSize;
|
||||
|
||||
/**
|
||||
* @var int The maximum number of workers the pool should spawn.
|
||||
*/
|
||||
/** @var int The maximum number of workers the pool should spawn. */
|
||||
private $maxSize;
|
||||
|
||||
/**
|
||||
* @var WorkerFactory A worker factory to be used to create new workers.
|
||||
*/
|
||||
/** @var WorkerFactory A worker factory to be used to create new workers. */
|
||||
private $factory;
|
||||
|
||||
/**
|
||||
* @var \SplObjectStorage A collection of all workers in the pool.
|
||||
*/
|
||||
/** @var \SplObjectStorage A collection of all workers in the pool. */
|
||||
private $workers;
|
||||
|
||||
/**
|
||||
* @var \SplQueue A collection of idle workers.
|
||||
*/
|
||||
/** @var \SplQueue A collection of idle workers. */
|
||||
private $idleWorkers;
|
||||
|
||||
/**
|
||||
* @var \SplQueue A queue of workers that have been assigned to tasks.
|
||||
*/
|
||||
/** @var \SplQueue A queue of workers that have been assigned to tasks. */
|
||||
private $busyQueue;
|
||||
|
||||
/**
|
||||
* @var \Closure
|
||||
*/
|
||||
/** @var \Closure */
|
||||
private $push;
|
||||
|
||||
/**
|
||||
|
@ -6,14 +6,10 @@ use Amp\Parallel\Worker\{ Task, Worker };
|
||||
use Interop\Async\Awaitable;
|
||||
|
||||
class PooledWorker implements Worker {
|
||||
/**
|
||||
* @var callable
|
||||
*/
|
||||
/** @var callable */
|
||||
private $push;
|
||||
|
||||
/**
|
||||
* @var \Amp\Parallel\Worker\Worker
|
||||
*/
|
||||
/** @var \Amp\Parallel\Worker\Worker */
|
||||
private $worker;
|
||||
|
||||
/**
|
||||
|
@ -7,14 +7,10 @@ use Amp\Parallel\{ Sync\Channel, Worker\Environment };
|
||||
use Interop\Async\Awaitable;
|
||||
|
||||
class TaskRunner {
|
||||
/**
|
||||
* @var \Amp\Parallel\Sync\Channel
|
||||
*/
|
||||
/** @var \Amp\Parallel\Sync\Channel */
|
||||
private $channel;
|
||||
|
||||
/**
|
||||
* @var \Amp\Parallel\Worker\Environment
|
||||
*/
|
||||
/** @var \Amp\Parallel\Worker\Environment */
|
||||
private $environment;
|
||||
|
||||
public function __construct(Channel $channel, Environment $environment) {
|
||||
|
@ -6,14 +6,10 @@ namespace Amp\Parallel\Worker;
|
||||
* An interface for worker pools.
|
||||
*/
|
||||
interface Pool extends Worker {
|
||||
/**
|
||||
* @var int The default minimum pool size.
|
||||
*/
|
||||
/** @var int The default minimum pool size. */
|
||||
const DEFAULT_MIN_SIZE = 4;
|
||||
|
||||
/**
|
||||
* @var int The default maximum pool size.
|
||||
*/
|
||||
/** @var int The default maximum pool size. */
|
||||
const DEFAULT_MAX_SIZE = 32;
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user