mirror of
https://github.com/amphp/parallel.git
synced 2025-01-17 20:58:36 +01:00
Add Strand; update some docblocks
This commit is contained in:
parent
cd8cc4ce9a
commit
9a0f48b076
13
CHANGELOG.md
13
CHANGELOG.md
@ -1,6 +1,17 @@
|
||||
# Change log
|
||||
All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/).
|
||||
|
||||
## [0.2.2] - 2015-12-21
|
||||
### Added
|
||||
- Added the `Icicle\Concurrent\Strand` interface that combines `Icicle\Concurrent\Context` and `Icicle\Concurrent\Sync\Channel`. This interface is implemented by the following classes (note that these classes implemented the two component interface separately, so no changes were made to the implementation):
|
||||
- `Icicle\Concurrent\Forking\Fork`
|
||||
- `Icicle\Concurrent\Threading\Thread`
|
||||
- `Icicle\Concurrent\Process\ChannelledProcess`
|
||||
|
||||
### Changed
|
||||
- `Icicle\Concurrent\Strand` interface is now required by the constructor of `Icicle\Concurrent\Worker\AbstractWorker`.
|
||||
|
||||
|
||||
## [0.2.1] - 2015-12-16
|
||||
### Added
|
||||
- Added `Icicle\Concurrent\Worker\DefaultQueue` implementing `Icicle\Concurrent\Worker\Queue` that provides a queue of workers that can be pulled and pushed from the queue as needed. Pulling a worker marks it as busy and pushing the worker back into the queue marks it as idle. If no idle workers remain in the queue, a worker is selected from those marked as busy. A worker queue allows a set of interdependent tasks (for example, tasks that depend on an environment value in the worker) to be run on a single worker without having to create and start separate workers for each task.
|
||||
@ -66,6 +77,8 @@ First release.
|
||||
- Non-blocking mutexes and semaphores for protecting parcels.
|
||||
|
||||
|
||||
[0.2.2]: https://github.com/icicleio/concurrent/releases/tag/v0.2.2
|
||||
[0.2.1]: https://github.com/icicleio/concurrent/releases/tag/v0.2.1
|
||||
[0.2.0]: https://github.com/icicleio/concurrent/releases/tag/v0.2.0
|
||||
[0.1.1]: https://github.com/icicleio/concurrent/releases/tag/v0.1.1
|
||||
[0.1.0]: https://github.com/icicleio/concurrent/releases/tag/v0.1.0
|
||||
|
@ -5,6 +5,7 @@ use Icicle\Concurrent\Exception\ForkException;
|
||||
use Icicle\Concurrent\Exception\StatusError;
|
||||
use Icicle\Concurrent\Exception\SynchronizationError;
|
||||
use Icicle\Concurrent\Process;
|
||||
use Icicle\Concurrent\Strand;
|
||||
use Icicle\Concurrent\Sync\Channel;
|
||||
use Icicle\Concurrent\Sync\ChannelledStream;
|
||||
use Icicle\Concurrent\Sync\Internal\ExitFailure;
|
||||
@ -20,7 +21,7 @@ use Icicle\Stream\Pipe\DuplexPipe;
|
||||
/**
|
||||
* Implements a UNIX-compatible context using forked processes.
|
||||
*/
|
||||
class Fork implements Channel, Process
|
||||
class Fork implements Process, Strand
|
||||
{
|
||||
/**
|
||||
* @var \Icicle\Concurrent\Sync\Channel A channel for communicating with the child.
|
||||
|
@ -4,12 +4,12 @@ namespace Icicle\Concurrent\Process;
|
||||
use Icicle\Concurrent\Exception\StatusError;
|
||||
use Icicle\Concurrent\Exception\SynchronizationError;
|
||||
use Icicle\Concurrent\Process as ProcessContext;
|
||||
use Icicle\Concurrent\Sync\Channel;
|
||||
use Icicle\Concurrent\Strand;
|
||||
use Icicle\Concurrent\Sync\ChannelledStream;
|
||||
use Icicle\Concurrent\Sync\Internal\ExitStatus;
|
||||
use Icicle\Exception\InvalidArgumentError;
|
||||
|
||||
class ChannelledProcess implements Channel, ProcessContext
|
||||
class ChannelledProcess implements ProcessContext, Strand
|
||||
{
|
||||
/**
|
||||
* @var \Icicle\Concurrent\Process\Process
|
||||
|
4
src/Strand.php
Normal file
4
src/Strand.php
Normal file
@ -0,0 +1,4 @@
|
||||
<?php
|
||||
namespace Icicle\Concurrent;
|
||||
|
||||
interface Strand extends Context, Sync\Channel {}
|
@ -33,7 +33,7 @@ interface Channel
|
||||
* @throws \Icicle\Concurrent\Exception\SynchronizationError If the context has not been started or the context
|
||||
* unexpectedly ends.
|
||||
* @throws \Icicle\Concurrent\Exception\ChannelException If sending on the channel fails.
|
||||
* @throws \Icicle\Concurrent\Exception\InvalidArgumentError If an ExitStatusInterface object is given.
|
||||
* @throws \Icicle\Exception\InvalidArgumentError If an ExitStatus object is given.
|
||||
*/
|
||||
public function send($data);
|
||||
}
|
||||
|
@ -1,11 +1,10 @@
|
||||
<?php
|
||||
namespace Icicle\Concurrent\Threading;
|
||||
|
||||
use Icicle\Concurrent\Context;
|
||||
use Icicle\Concurrent\Exception\StatusError;
|
||||
use Icicle\Concurrent\Exception\SynchronizationError;
|
||||
use Icicle\Concurrent\Exception\ThreadException;
|
||||
use Icicle\Concurrent\Sync\Channel;
|
||||
use Icicle\Concurrent\Strand;
|
||||
use Icicle\Concurrent\Sync\ChannelledStream;
|
||||
use Icicle\Concurrent\Sync\Internal\ExitStatus;
|
||||
use Icicle\Coroutine;
|
||||
@ -21,7 +20,7 @@ use Icicle\Stream\Pipe\DuplexPipe;
|
||||
* maintained both in the context that creates the thread and in the thread
|
||||
* itself.
|
||||
*/
|
||||
class Thread implements Channel, Context
|
||||
class Thread implements Strand
|
||||
{
|
||||
/**
|
||||
* @var Internal\Thread An internal thread instance.
|
||||
|
@ -2,7 +2,7 @@
|
||||
namespace Icicle\Concurrent\Worker;
|
||||
|
||||
use Icicle\Awaitable\Delayed;
|
||||
use Icicle\Concurrent\Context;
|
||||
use Icicle\Concurrent\Strand;
|
||||
use Icicle\Concurrent\Exception\StatusError;
|
||||
use Icicle\Concurrent\Exception\WorkerException;
|
||||
use Icicle\Concurrent\Worker\Internal\TaskFailure;
|
||||
@ -13,7 +13,7 @@ use Icicle\Concurrent\Worker\Internal\TaskFailure;
|
||||
abstract class AbstractWorker implements Worker
|
||||
{
|
||||
/**
|
||||
* @var \Icicle\Concurrent\Context
|
||||
* @var \Icicle\Concurrent\Strand
|
||||
*/
|
||||
private $context;
|
||||
|
||||
@ -39,11 +39,11 @@ abstract class AbstractWorker implements Worker
|
||||
|
||||
|
||||
/**
|
||||
* @param \Icicle\Concurrent\Context $context
|
||||
* @param \Icicle\Concurrent\Strand $strand
|
||||
*/
|
||||
public function __construct(Context $context)
|
||||
public function __construct(Strand $strand)
|
||||
{
|
||||
$this->context = $context;
|
||||
$this->context = $strand;
|
||||
$this->busyQueue = new \SplQueue();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user