This source file is subject to the new BSD license that is bundled
with this package in the file LICENSE.txt.
It is also available through the world-wide-web at this URL:
http://framework.zend.com/license/new-bsd
If you did not receive a copy of the license and are unable to
obtain it through the world-wide-web, please send an email
to license@zend.com so we can send you a copy immediately.
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.
This method actually implements the pseudo-thread logic.
Return value
Type
Description
void
_sendSigUsr1(
)
:
void
Description
Sends signal to the child process
Return value
Type
Description
void
_setAlive(
)
:
void
Description
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...
Return value
Type
Description
void
_sigHandler(
integer
$signo,
)
:
void
Description
This is the signal handler that makes the communications between client
and server possible.
Acutally Write a variable to the shared memory segment
Arguments
Name
Type
Description
Default
$name
string |
$value
mixed |
Return value
Type
Description
void
getLastAlive(
)
:
integer
Description
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.
Return value
Type
Description
integer
getPid(
)
:
integer
Description
Returns the PID of the current pseudo-thread.
Return value
Type
Description
integer
getVariable(
string
$name,
)
:
mixed
Description
Get a variable from the shared memory segment. Returns NULL if the
variable doesn't exist.
Arguments
Name
Type
Description
Default
$name
string |
Return value
Type
Description
mixed
isRunning(
)
:
boolean
Description
Test if the pseudo-thread is already started.
Return value
Type
Description
boolean
setVariable(
string
$name,
mixed
$value,
)
:
void
Description
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.
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).