Source for file basic.php
Documentation is available at basic.php
* PHP_Fork class usage examples
* ==================================================================================
* NOTE: In real world you surely want to keep each class into
* a separate file, then include() it into your application.
* For this examples is more useful to keep all_code_into_one_file,
* so that each example shows a unique feature of the PHP_Fork framework.
* ==================================================================================
* This is the most basic example I can think about...
* Simply increment an internal counter every second, printing it to
* stdout. Repeat this 10 times, then exit. The class extends PHP_Fork, so we have
* multiple instances running cuncurrently, as shown by the timestamp of each thread.
* ==================================================================================
require_once ("PHP/Fork.php");
// number of executeThreads we want
// Class definition; this class have a very basic purpose,, it simply
// has an inernal counter and increment it every each second...
print time() . "-(" . $this->getName () . ")-" . $this->counter++ . "\n";
// Main program. Bring up NUM_THREAD instances of the executeThread class that
// runs concurrently. It's a multi-thread app with a few lines of code!!!
$executeThread[$i]->start ();
echo "Started " . $executeThread[$i]->getName () . " with PID " . $executeThread[$i]->getPid () . "...\n";
echo "\nThis is the main process.\nNothing to do, so exit...\n";
Documentation generated on Mon, 11 Mar 2019 15:41:27 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|