1
0
mirror of https://github.com/danog/parallel.git synced 2025-01-22 05:51:14 +01:00

Add missed owner property; other minor fixes

This commit is contained in:
Aaron Piotrowski 2015-09-19 21:34:41 -05:00
parent 4eb815ea45
commit a236585aae
2 changed files with 19 additions and 13 deletions

View File

@ -6,7 +6,6 @@ use Icicle\Concurrent\Exception\InvalidArgumentError;
use Icicle\Concurrent\Exception\StatusError;
use Icicle\Concurrent\Exception\SynchronizationError;
use Icicle\Concurrent\Sync\Channel;
use Icicle\Concurrent\Sync\ChannelInterface;
use Icicle\Concurrent\Sync\Internal\ExitStatusInterface;
class ChannelledProcess implements ContextInterface
@ -65,7 +64,7 @@ class ChannelledProcess implements ContextInterface
*/
public function receive()
{
if (!$this->channel instanceof ChannelInterface) {
if (null === $this->channel) {
throw new StatusError('The process has not been started.');
}
@ -87,7 +86,7 @@ class ChannelledProcess implements ContextInterface
*/
public function send($data)
{
if (!$this->channel instanceof ChannelInterface) {
if (null === $this->channel) {
throw new StatusError('The process has not been started.');
}
@ -103,7 +102,7 @@ class ChannelledProcess implements ContextInterface
*/
public function join()
{
if (!$this->channel instanceof ChannelInterface) {
if (null === $this->channel) {
throw new StatusError('The process has not been started.');
}
@ -128,5 +127,6 @@ class ChannelledProcess implements ContextInterface
public function kill()
{
$this->process->kill();
$this->channel->close();
}
}

View File

@ -56,6 +56,11 @@ class Process
*/
private $pid = 0;
/**
* @var int
*/
private $oid = 0;
/**
* @var \Icicle\Promise\PromiseInterface|null
*/
@ -97,18 +102,18 @@ class Process
{
if (getmypid() === $this->oid) {
$this->kill(); // Will only terminate if the process is still running.
}
if (null !== $this->stdin) {
$this->stdin->close();
}
if (null !== $this->stdin) {
$this->stdin->close();
}
if (null !== $this->stdout) {
$this->stdout->close();
}
if (null !== $this->stdout) {
$this->stdout->close();
}
if (null !== $this->stderr) {
$this->stderr->close();
if (null !== $this->stderr) {
$this->stderr->close();
}
}
}
@ -121,6 +126,7 @@ class Process
$this->promise = null;
$this->poll = null;
$this->pid = 0;
$this->oid = 0;
$this->stdin = null;
$this->stdout = null;
$this->stderr = null;