Update README.md, consistent use of spaces instead of tabs, better examples
This commit is contained in:
@@ -4,25 +4,25 @@ namespace Toalett\Multiprocessing\ProcessControl;
|
||||
|
||||
class Fork
|
||||
{
|
||||
public int $pid;
|
||||
public int $pid;
|
||||
|
||||
public function __construct(int $pid)
|
||||
{
|
||||
$this->pid = $pid;
|
||||
}
|
||||
public function __construct(int $pid)
|
||||
{
|
||||
$this->pid = $pid;
|
||||
}
|
||||
|
||||
public function failed(): bool
|
||||
{
|
||||
return $this->pid < 0;
|
||||
}
|
||||
public function failed(): bool
|
||||
{
|
||||
return $this->pid < 0;
|
||||
}
|
||||
|
||||
public function isChild(): bool
|
||||
{
|
||||
return $this->pid === 0;
|
||||
}
|
||||
public function isChild(): bool
|
||||
{
|
||||
return $this->pid === 0;
|
||||
}
|
||||
|
||||
public function isParent(): bool
|
||||
{
|
||||
return $this->pid !== 0;
|
||||
}
|
||||
public function isParent(): bool
|
||||
{
|
||||
return $this->pid !== 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,15 +4,15 @@ namespace Toalett\Multiprocessing\ProcessControl;
|
||||
|
||||
class PCNTL implements ProcessControl
|
||||
{
|
||||
public function fork(): Fork
|
||||
{
|
||||
$pid = pcntl_fork();
|
||||
return new Fork($pid);
|
||||
}
|
||||
public function fork(): Fork
|
||||
{
|
||||
$pid = pcntl_fork();
|
||||
return new Fork($pid);
|
||||
}
|
||||
|
||||
public function wait(int $options = 0): Wait
|
||||
{
|
||||
$pid = pcntl_wait($status, $options);
|
||||
return new Wait($pid, $status);
|
||||
}
|
||||
public function wait(int $options = 0): Wait
|
||||
{
|
||||
$pid = pcntl_wait($status, $options);
|
||||
return new Wait($pid, $status);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace Toalett\Multiprocessing\ProcessControl;
|
||||
|
||||
interface ProcessControl
|
||||
{
|
||||
public function fork(): Fork;
|
||||
public function fork(): Fork;
|
||||
|
||||
public function wait(int $options = 0): Wait;
|
||||
public function wait(int $options = 0): Wait;
|
||||
}
|
||||
|
||||
@@ -4,24 +4,24 @@ namespace Toalett\Multiprocessing\ProcessControl;
|
||||
|
||||
class Wait
|
||||
{
|
||||
public const NO_HANG = WNOHANG;
|
||||
public const UNTRACED = WUNTRACED;
|
||||
public int $pid;
|
||||
public int $status;
|
||||
public const NO_HANG = WNOHANG;
|
||||
public const UNTRACED = WUNTRACED;
|
||||
public int $pid;
|
||||
public int $status;
|
||||
|
||||
public function __construct(int $pid, int $status = 0)
|
||||
{
|
||||
$this->pid = $pid;
|
||||
$this->status = $status;
|
||||
}
|
||||
public function __construct(int $pid, int $status = 0)
|
||||
{
|
||||
$this->pid = $pid;
|
||||
$this->status = $status;
|
||||
}
|
||||
|
||||
public function childStopped(): bool
|
||||
{
|
||||
return $this->pid > 0;
|
||||
}
|
||||
public function childStopped(): bool
|
||||
{
|
||||
return $this->pid > 0;
|
||||
}
|
||||
|
||||
public function failed(): bool
|
||||
{
|
||||
return $this->pid < 0;
|
||||
}
|
||||
public function failed(): bool
|
||||
{
|
||||
return $this->pid < 0;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user