mirror of
https://github.com/danog/parallel.git
synced 2025-01-22 14:01:14 +01:00
Add missed owner property; other minor fixes
This commit is contained in:
parent
4eb815ea45
commit
a236585aae
@ -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();
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user