Recommend this page to a friend! |
Download .zip |
Info | View files (18) | Download .zip | Reputation | Support forum (2) | Blog | Links |
Last Updated | Ratings | Unique User Downloads | Download Rankings | |||||
2012-01-11 (4 years ago) | Not enough user ratings | Total: 293 | All time: 7,033 This week: 872 |
Version | License | PHP version | Categories | |||
power-process 2.0 | MIT/X Consortium ... | 5.3 | PHP 5, Unix, Language |
Description | Author | |||||||||||||
This class can create processes to PHP code in parallel. |
|
ABOUT PowerProcess is a PCNTL and POSIX wrapper for *nix systems running PHP It is for managing and running forked process for parrallel computing with PHP FEATURES * Easy Process Threading for Parallel Computing * Named Thread Support * Linux/Unix Signal Handling * Daemonizing PHP Scripts * Automatic Ticks (No longer have to add calls to Tick() in loops) * Dynamic callback support for *nix signals and custom events * Process Space Takeover Ability VERSION HISTORY 2.0 - 2011-12-29 Added Restart() Added Daemonize() Changed a number of method names Added Log() Added config options to constructor Added Linux/Unix signal handlers for SIGHUP and SIGTERM 1.1 - 2011-11-12 Added named thread support Added ThreadStatus check support 1.0 - 2011-11-01 Forked from PowerSpawn 1.0 IMPORTANT NOTE PowerProcess is very similar to PowerSpawn, however, more features are available in PowerProcess and it is not backwards compatible. Changes to convert code to PowerProcess are minimal and should be easy enough for you if you have experience with PowerSpawn ANOTHER IMPORTANT NOTE Open database connections made in the control process do not carry over to the threads. This means if you are doing work with a MySQL (or other) database, you will need to open a new database connection in the thread code. HOW TO USE To use PowerProcess, once included you just need to simply instance the class like so: $pp = new PowerProcess(); This will enable threading and daemon capabilities for your code. Now that you have instanced the class, you will need to set up your control loop like so: while ( $pp->RunControlCode() ) { if ( __SOME_CONDITION_THAT_DETERMINES_IF_YOU_HAVE_DATA_TO_PROCESS__ ) { $pp->threadData = __YOUR_DATA__; $pp->SpawnThread(); } else { $pp->Shutdown(); } } That is what a basic control loop will look like. When a new thread is spawned, it will resume execution from the SpawnThread() method call. It will break out of the while loop and execute any code below the end of the while loop as a separate process than the one you started. When the Shutdown() method is called, the Control Loop will wait for all running threads to exit and it too will break out of the while loop and resume executing the rest of the script. If you don't want to control process to execute the code below the loop, you have two options to prevent it from doing do. First, you should call shutdown with an extra parameter: $pp->Shutdown(true) This will make shutdown call exit() after all threads have completed. Second, you can wrap all the code you don't want the exiting control process to execute inside of and if{} statement like so: if ($pp->RunThreadCode()) { // My Code Here } MAKING A DAEMON You don't have to use PowerProcess for threading. You can also use it to create a PHP deamon. You simply instance the PowerProcess object by setting the daemon parameter to true. $pp = new PowerProcess(1,0,true); // 1 Thread, No Timeout, Daemon set to true Please check the examples included for more information on how to use PowerProcess |
Files |
File | Role | Description | ||
---|---|---|---|---|
docs (7 files, 3 directories) | ||||
examples (3 files) | ||||
LICENSE | Lic. | License text | ||
PowerProcess.class.php | Class | Class source | ||
README | Doc. | Documentation |
Files | / | docs |
File | Role | Description | ||
---|---|---|---|---|
media (2 files) | ||||
PowerProcess (2 files) | ||||
__filesource (1 file) | ||||
blank.html | Doc. | Documentation | ||
classtrees_PowerProcess.html | Doc. | Documentation | ||
elementindex.html | Doc. | Documentation | ||
elementindex_PowerProcess.html | Doc. | Documentation | ||
index.html | Doc. | Documentation | ||
li_PowerProcess.html | Doc. | Documentation | ||
packages.html | Doc. | Documentation |
Files | / | docs | / | media |
File | Role | Description |
---|---|---|
banner.css | Data | Auxiliary data |
stylesheet.css | Data | Auxiliary data |
Files | / | docs | / | PowerProcess |
File | Role | Description |
---|---|---|
PowerProcess.html | Doc. | Documentation |
_PowerProcess.class.php.html | Doc. | Documentation |
Files | / | docs | / | __filesource |
File | Role | Description |
---|---|---|
fsource_PowerProce...cess.class.php.html | Doc. | Documentation |
Files | / | examples |
File | Role | Description |
---|---|---|
example.deamon.php | Example | Example script |
example.namedThreads.php | Example | Example script |
example.normal.php | Example | Example script |
Version Control | Unique User Downloads | Download Rankings | |||||||||||||||
100% |
|
|
User Comments (2) | ||||||||
|
Applications that use this package |
If you know an application of this package, send a message to the author to add a link here.
Related pages |
GitHub Repo Link to PowerProcess on Github |