ZendX_Console_Process_UnixIntroduction
Basic usage of ZendX_Console_Process_Unix
The
Example #1 Basic example for processing This example illustrates a basic child process
class MyProcess extends ZendX_Console_Process_Unix
{
protected function _run()
{
for ($i = 0; $i < 10; $i++) {
// Doing something really important which can't wait: sleeping
sleep(1);
}
}
}
// This part should last about 10 seconds, not 20.
$process1 = new MyProcess();
$process1->start();
$process2 = new MyProcess();
$process2->start();
while ($process1->isRunning() && $process2->isRunning()) {
sleep(1);
}
echo 'All processes completed';
In this example a process is forked twice and executed. As every process runs 10 seconds, the parent process will be finished after 10 seconds (and not 20).
|