PHP Classes
elePHPant
Icontem

Thread: A class to implement multi-threaded applications

Recommend this page to a friend!
  Info   View files View files (8)   DownloadInstall with Composer Download .zip   Reputation   Support forum (1)   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2003-12-09 (13 years ago) RSS 2.0 feedStarStarStarStar 62%Total: 8,653 This week: 2All time: 182 This week: 331Down
Version License Categories
php_fork 1.0.0The PHP LicenseUnix, Language
Description Author

Wrapper around the pcntl_fork() stuff, with a API set like Java language.
Practical usage is done by extending this class, and re-defining the run() method.
This way PHP developers can enclose logic into a class that extends PHP_Fork, then execute the start() method that forks a child process.
Communications with the forked process is ensured by using a Shared Memory Segment; by using a user-defined signal and this shared memory developers can access to child process methods that returns a serializable variable.

The shared variable space can be accessed with the tho methods:
o void setVariable($name, $value)
o mixed getVariable($name)

$name must be a valid PHP variable name;
$value must be a variable or a serializable object.
Resources (db connections, streams, etc.) cannot be serialized and so they're not correctly handled.

Only runs on *NIX systems, because Windows lacks of the needed pcntl ext.

Recommendations

Threads PHP
php_fork

Name: Luca Mariano <contact>
Classes: 1 package by
Country: Italy Italy
Age: 42
All time rank: 28810 in Italy Italy
Week rank: 330 Down19 in Italy Italy Down

  Files folder image Files  
File Role Description
Accessible without login Plain text file action_dispatcher.php Example shows a multiprocess application scheme where all processes run a sleep() cycle, and a centralized dispatcher pass them the work.
Accessible without login Plain text file basic.php Example a basic example, only two pseudo-threads that increment a counter simultaneously
Accessible without login Plain text file exec_methods.php Example shows how to execute methods into the child process.
Plain text file Fork.php Class Main class
Accessible without login Plain text file INSTALL Doc. installation instructions
Accessible without login Plain text file passing_vars.php Example shows variable exchange between the parent process and started pseudo-threads.
Accessible without login HTML file php_fork-api.html Doc. API docs
Accessible without login Plain text file simple_controller.php Example shows how to attach a controller to started pseudo-threads.

 Version Control Reuses Unique User Downloads Download Rankings  
 0%2
Total:8,653
This week:2
All time:182
This week:331Down
 User Ratings  
 
 All time
Utility:76%StarStarStarStar
Consistency:82%StarStarStarStarStar
Documentation:76%StarStarStarStar
Examples:80%StarStarStarStarStar
Tests:-
Videos:-
Overall:62%StarStarStarStar
Rank:1078