PHP Class Jenner\SimpleFork\Process

Afficher le fichier Open project: huyanping/simple-fork-php Class Usage Examples

Protected Properties

Свойство Type Description
$callbacks array
$errmsg error message
$errno error code
$if_signal boolean
$name custom process name
$pid integer
$runnable Jenner\SimpleFork\Runnable | callable
$running boolean
$signal_handlers signal handlers
$started if the process is started
$stop_signal the signal which made the process stop
$term_signal the signal which made the process terminate

Méthodes publiques

Méthode Description
__construct ( string $execution = null, null $name = null )
errmsg ( ) : string get pcntl errmsg
errno ( ) : integer get pcntl errno
getPid ( ) : integer get pid
ifSignal ( )
isRunning ( ) : boolean if the process is running
isStarted ( ) : boolean if the process is started
isStopped ( ) : boolean if the process is stopped
name ( string | null $name = null ) : mixed get or set name
registerSignalHandler ( $signal, callable $handler ) register sub process signal handler, when the sub process start, the handlers will be registered
run ( ) you should overwrite this function if you do not use the Runnable or callback.
shutdown ( boolean | true $block = true, integer $signal = SIGTERM ) kill self
start ( ) : string start the sub process and run the callback
wait ( boolean | true $block = true, integer $sleep = 100000 ) waiting for the sub process exit

Méthodes protégées

Méthode Description
getCallable ( ) : array | callable | null get sub process callback
initStatus ( ) init process status
signal ( ) register signal SIGTERM handler, when the parent process call shutdown and use the default signal, this handler will be triggered
updateStatus ( boolean $block = false ) update the process status

Method Details

__construct() public méthode

public __construct ( string $execution = null, null $name = null )
$execution string it can be a Runnable object, callback function or null
$name null process name,you can manager the process by it's name.

errmsg() public méthode

get pcntl errmsg
public errmsg ( ) : string
Résultat string

errno() public méthode

get pcntl errno
public errno ( ) : integer
Résultat integer

getCallable() protected méthode

get sub process callback
protected getCallable ( ) : array | callable | null
Résultat array | callable | null

getPid() public méthode

get pid
public getPid ( ) : integer
Résultat integer

ifSignal() public méthode

public ifSignal ( )

initStatus() protected méthode

init process status
protected initStatus ( )

isRunning() public méthode

if the process is running
public isRunning ( ) : boolean
Résultat boolean

isStarted() public méthode

if the process is started
public isStarted ( ) : boolean
Résultat boolean

isStopped() public méthode

if the process is stopped
public isStopped ( ) : boolean
Résultat boolean

name() public méthode

get or set name
public name ( string | null $name = null ) : mixed
$name string | null
Résultat mixed

registerSignalHandler() public méthode

register sub process signal handler, when the sub process start, the handlers will be registered
public registerSignalHandler ( $signal, callable $handler )
$signal
$handler callable

run() public méthode

you should overwrite this function if you do not use the Runnable or callback.
public run ( )

shutdown() public méthode

kill self
public shutdown ( boolean | true $block = true, integer $signal = SIGTERM )
$block boolean | true
$signal integer

signal() protected méthode

register signal SIGTERM handler, when the parent process call shutdown and use the default signal, this handler will be triggered
protected signal ( )

start() public méthode

start the sub process and run the callback
public start ( ) : string
Résultat string pid

updateStatus() protected méthode

update the process status
protected updateStatus ( boolean $block = false )
$block boolean

wait() public méthode

waiting for the sub process exit
public wait ( boolean | true $block = true, integer $sleep = 100000 )
$block boolean | true if block the process
$sleep integer default 0.1s check sub process status every $sleep milliseconds.

Property Details

$callbacks protected_oe property

protected array $callbacks
Résultat array

$errmsg protected_oe property

error message
protected $errmsg

$errno protected_oe property

error code
protected $errno

$if_signal protected_oe property

protected bool $if_signal
Résultat boolean

$name protected_oe property

custom process name
protected $name

$pid protected_oe property

protected int $pid
Résultat integer

$runnable protected_oe property

protected Runnable,Jenner\SimpleFork|callable $runnable
Résultat Jenner\SimpleFork\Runnable | callable

$running protected_oe property

protected bool $running
Résultat boolean

$signal_handlers protected_oe property

signal handlers
protected $signal_handlers

$started protected_oe property

if the process is started
protected $started

$stop_signal protected_oe property

the signal which made the process stop
protected $stop_signal

$term_signal protected_oe property

the signal which made the process terminate
protected $term_signal