## ZendX_Console_Process_Unix

Description

ZendX_Console_Process_Unix allows you to spawn a class as a separated process

- copyright: Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
- abstract:
- license: New BSD License

Located in /Console/Process/Unix.php (line 31)

Class Constant Summary
RETURN_METHOD = 'void_method'
VOID_METHOD = 'void_method'
Method Summary
ZendX_Console_Process_Unix __construct ([integer $puid = null], [integer $guid = null], [integer $umask = null])
void __destruct ()
integer getLastAlive ()
integer getPid ()
mixed getVariable (string $name)
boolean isRunning ()
void setVariable (string $name, mixed $value)
void start ()
boolean stop ()
mixed _callCallbackMethod (string $methodName, [ $argList = array()], [string $type = self::VOID_METHOD])
void _run ()
void _setAlive ()
Methods
Constructor __construct (line 144)

Constructor method

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.

- throws: ZendX_Console_Process_Exception When running on windows
- throws: ZendX_Console_Process_Exception When running in web enviroment
- throws: ZendX_Console_Process_Exception When shmop_* functions don't exist
- throws: ZendX_Console_Process_Exception When posix_* functions don't exist
- throws: ZendX_Console_Process_Exception When pcntl_* functions don't exist
- access: public

ZendX_Console_Process_Unix __construct ([integer $puid = null], [integer $guid = null], [integer $umask = null])

- integer $puid
- integer $guid
- integer $umask

Destructor __destruct (line 186)

Stop the child on destruction

- access: public

void __destruct ()
getLastAlive (line 343)

Read the time elapsed since the last child setAlive() call.

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.

- access: public

integer getLastAlive ()
getPid (line 355)

Returns the PID of the current pseudo-thread.

- access: public

integer getPid ()
getVariable (line 322)

Get a variable from the shared memory segment. Returns NULL if the variable doesn't exist.

- access: public

mixed getVariable (string $name)

- string $name

isRunning (line 290)

Test if the pseudo-thread is already started.

- access: public

boolean isRunning ()
setVariable (line 305)

Set a variable into the shared memory segment, so that it can accessed both from the parent and from the child process. Variable names beginning with underlines are only permitted to interal functions.

- throws: ZendX_Console_Process_Exception When an invalid variable name is supplied
- access: public

void setVariable (string $name, mixed $value)

- string $name
- mixed $value

start (line 207)

Causes this pseudo-thread to begin parallel execution.

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).

- throws: ZendX_Console_Process_Exception When process forking fails
- throws: ZendX_Console_Process_Exception When SHM segments can't be created
- access: public

void start ()
stop (line 269)

Causes the current thread to die.

The relative process is killed and disappears immediately from the processes list.

- access: public

boolean stop ()
_callCallbackMethod (line 385)

This is called from within the parent; all the communication stuff is done here.

- access: protected

mixed _callCallbackMethod (string $methodName, [ $argList = array()], [string $type = self::VOID_METHOD])

- string $methodName
- array $argList
- string $type

_run (line 436)

This method actually implements the pseudo-thread logic.

- abstract:
- access: protected

void _run ()
_setAlive (line 370)

Set a pseudo-thread property that can be read from parent process in order to know the child activity.

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...

- access: protected

void _setAlive ()
Class Constants
RETURN_METHOD = 'void_method' (line 41)

Return method

VOID_METHOD = 'void_method' (line 36)

Void method

Documentation generated on Mon, 24 Aug 2009 17:58:51 -0700 by phpDocumentor 1.4.2