ZendX_Console_Process_Unix allows you to spawn a class as a separated process
category | ZendX |
---|---|
package | ZendX_Console |
copyright | Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) |
license | New BSD License |
__construct(integer $puid= null
, integer $guid= null
, integer $umask= null
)
Allocates a new pseudo-thread object. Optionally, set a PUID, a GUID and a UMASK for the child process. This also initialize Shared Memory Segments for process communications.
integer
integer
integer
\ZendX_Console_Process_Exception |
When running on windows |
---|---|
\ZendX_Console_Process_Exception |
When running in web enviroment |
\ZendX_Console_Process_Exception |
When shmop_* functions don't exist |
\ZendX_Console_Process_Exception |
When pcntl_* functions don't exist |
\ZendX_Console_Process_Exception |
When posix_* functions don't exist |
__destruct()
getLastAlive() : integer
This method is useful because often we have a pseudo-thread pool and we need to know each pseudo-thread status. If the child executes the setAlive() method, the parent with getLastAlive() can know that child is alive.
integer
getPid() : integer
integer
getVariable(string $name) : mixed
string
mixed
isRunning() : boolean
boolean
setVariable(string $name, mixed $value) : void
string
mixed
\ZendX_Console_Process_Exception |
When an invalid variable name is supplied |
---|
start() : void
This method first checks of all the Shared Memory Segment. If okay, it forks the child process, attaches signal handler and returns immediatly. The status is set to running, and a PID is assigned. The result is that two pseudo-threads are running concurrently: the current thread (which returns from the call to the start() method) and the other thread (which executes its run() method).
\ZendX_Console_Process_Exception |
When SHM segments can't be created |
---|---|
\ZendX_Console_Process_Exception |
When process forking fails |
stop() : boolean
The relative process is killed and disappears immediately from the processes list.
boolean
_callCallbackMethod(string $methodName, array $argList= array()
, string $type= self::VOID_METHOD
) : mixed
string
array
string
mixed
_run() : void
_setAlive() : void
Practical usage requires that child process calls this method at regular time intervals; parent will use the getLastAlive() method to know the elapsed time since the last pseudo-thread life signals...
_cleanProcessContext() : void
_createIpcSegment() : boolean
\ZendX_Console_Process_Exception |
When SHM segment can't be created |
---|
boolean
_createIpcSemaphore() : boolean
\ZendX_Console_Process_Exception |
When semaphore can't be created |
---|
boolean
_readFromIpcSegment() : void
\ZendX_Console_Process_Exception |
When writing of SHM segment fails |
---|
_sendSigUsr1() : void
_sigHandler(integer $signo) : void
integer
_waitForIpcSemaphore() : void
_writeToIpcSegment() : void
\ZendX_Console_Process_Exception |
When writing of SHM segment fails |
---|
_writeVariable(string $name, mixed $value) : void
string
mixed
$_guid : integer
null
$_internalIpcData : array
array()
$_internalIpcKey : integer
$_internalSemKey : integer
$_ipcIsOkay : boolean
Otherwise we'll have a running child without any communication channel.
$_ipcSegFile : string
$_ipcSemFile : string
$_isChild : boolean
false
$_isRunning : boolean
false
$_name : string
$_pid : integer
null
$_puid : integer
null
RETURN_METHOD = 'void_method'
VOID_METHOD = 'void_method'