PHP Class PHPDaemon\Thread\Generic

Author: Vasily Zorin ([email protected])
Inheritance: use trait PHPDaemon\Traits\ClassWatchdog, use trait PHPDaemon\Traits\StaticObjectWatchdog
Exibir arquivo Open project: kakserpom/phpdaemon Class Usage Examples

Public Properties

Property Type Description
$id integer Process identificator
$signals array ..]

Protected Properties

Property Type Description
$collections array | Collection[] Collections of childrens
$delayedSigReg boolean If true, we do not register signals automatically at start
$pid integer PID
$shutdown boolean Is this thread shutdown?
$sigEvents array Storage of signal handler events
$terminated boolean Is this thread terminated?

Public Methods

Method Description
__invoke ( ) : void Invoke magic method
eventSighandler ( $fd, $arg ) : void Called when a signal caught through libevent.
getId ( ) : integer Get ID of this Thread
getPid ( ) : integer Get PID of this Thread
ifExists ( ) : boolean Checks if this process does exist
ifExistsByPid ( integer $pid ) : boolean Checks if given process ID does exist
isTerminated ( ) : boolean Is this thread terminated?
setId ( $id ) : void Set ID of this Thread
setTerminated ( )
sighandler ( $signo ) : void Called when the signal is caught
signal ( $sig ) : boolean Sends arbitrary signal to the process
sleep ( $s ) : boolean Delays the process execution for the given number of seconds
start ( $clearstack = true ) : void Starts the process
stop ( $kill = false ) : void Terminates the process

Protected Methods

Method Description
backsig ( $sig ) : boolean Sends the signal to parent process
getTitle ( ) : string Returns a title of the current process
onTerminated ( )
registerEventSignals ( ) : void Register signals.
registerSignals ( ) : void Registers signals
run ( ) : void Run thread process
setTitle ( string $title ) : boolean Sets a title of the current process
shutdown ( ) : void Shutdowns the current process properly
sigchld ( ) : void Called when the signal SIGCHLD caught
sigint ( ) : void Called when the signal SIGINT caught
sigkill ( ) : void Called when the signal SIGKILL caught
sigquit ( ) : void Called when the signal SIGTERM caught
sigterm ( ) : void Called when the signal SIGTERM caught
sigtimedwait ( $signals, $siginfo, integer $sec, double $nano ) : boolean Implementation of pcntl_sigtimedwait for Mac.
sigwait ( $sec, $nano = 300000000 ) : boolean Waits for signals, with a timeout
unregisterSignals ( ) : void Unregister signals.
waitAll ( boolean $check ) : void Waits until children is alive
waitPid ( ) : boolean Checks for SIGCHLD

Method Details

__invoke() public method

Invoke magic method
public __invoke ( ) : void
return void

backsig() protected method

Sends the signal to parent process
protected backsig ( $sig ) : boolean
return boolean Success

eventSighandler() public method

Called when a signal caught through libevent.
public eventSighandler ( $fd, $arg ) : void
return void

getId() public method

Get ID of this Thread
public getId ( ) : integer
return integer

getPid() public method

Get PID of this Thread
public getPid ( ) : integer
return integer

getTitle() protected method

Returns a title of the current process
protected getTitle ( ) : string
return string

ifExists() public method

Checks if this process does exist
public ifExists ( ) : boolean
return boolean Success

ifExistsByPid() public static method

Checks if given process ID does exist
public static ifExistsByPid ( integer $pid ) : boolean
$pid integer
return boolean Success

isTerminated() public method

Is this thread terminated?
public isTerminated ( ) : boolean
return boolean

onTerminated() protected method

protected onTerminated ( )

registerEventSignals() protected method

Register signals.
protected registerEventSignals ( ) : void
return void

registerSignals() protected method

Registers signals
protected registerSignals ( ) : void
return void

run() protected method

Run thread process
protected run ( ) : void
return void

setId() public method

Set ID of this Thread
public setId ( $id ) : void
return void

setTerminated() public method

public setTerminated ( )

setTitle() protected method

Sets a title of the current process
protected setTitle ( string $title ) : boolean
$title string
return boolean Success

shutdown() protected method

Shutdowns the current process properly
protected shutdown ( ) : void
return void

sigchld() protected method

Called when the signal SIGCHLD caught
protected sigchld ( ) : void
return void

sighandler() public method

Called when the signal is caught
public sighandler ( $signo ) : void
return void

sigint() protected method

Called when the signal SIGINT caught
protected sigint ( ) : void
return void

sigkill() protected method

Called when the signal SIGKILL caught
protected sigkill ( ) : void
return void

signal() public method

Sends arbitrary signal to the process
public signal ( $sig ) : boolean
return boolean Success

sigquit() protected method

Called when the signal SIGTERM caught
protected sigquit ( ) : void
return void

sigterm() protected method

Called when the signal SIGTERM caught
protected sigterm ( ) : void
return void

sigtimedwait() protected method

Implementation of pcntl_sigtimedwait for Mac.
protected sigtimedwait ( $signals, $siginfo, integer $sec, double $nano ) : boolean
$sec integer
$nano double
return boolean Success

sigwait() protected method

Waits for signals, with a timeout
protected sigwait ( $sec, $nano = 300000000 ) : boolean
return boolean Success

sleep() public method

Delays the process execution for the given number of seconds
public sleep ( $s ) : boolean
return boolean Success

start() public method

Starts the process
public start ( $clearstack = true ) : void
return void

stop() public method

Terminates the process
public stop ( $kill = false ) : void
return void

unregisterSignals() protected method

Unregister signals.
protected unregisterSignals ( ) : void
return void

waitAll() protected method

Waits until children is alive
protected waitAll ( boolean $check ) : void
$check boolean
return void

waitPid() protected method

Checks for SIGCHLD
protected waitPid ( ) : boolean
return boolean Success

Property Details

$collections protected_oe property

Collections of childrens
protected array|Collection[],PHPDaemon\Thread $collections
return array | Collection[]

$delayedSigReg protected_oe property

If true, we do not register signals automatically at start
protected bool $delayedSigReg
return boolean

$id public_oe property

Process identificator
public int $id
return integer

$pid protected_oe property

PID
protected int $pid
return integer

$shutdown protected_oe property

Is this thread shutdown?
protected bool $shutdown
return boolean

$sigEvents protected_oe property

Storage of signal handler events
protected array $sigEvents
return array

$signals public_oe static_oe property

..]
public static array $signals
return array

$terminated protected_oe property

Is this thread terminated?
protected bool $terminated
return boolean