Update README.md, consistent use of spaces instead of tabs, better examples

This commit is contained in:
2020-12-12 13:05:48 +01:00
parent 92bc0ab407
commit db081158d7
30 changed files with 997 additions and 1041 deletions

View File

@@ -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;
}
}

View File

@@ -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);
}
}

View File

@@ -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;
}

View File

@@ -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;
}
}