Created
November 26, 2010 15:59
-
-
Save mtrudel/716883 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function run_function($name, $params) { | |
| // Actually run the function in question | |
| } | |
| while(true) { | |
| // Wait for a connection and extract the function to start | |
| if (function_exists('pcntl_fork')) { | |
| $pid = pcntl_fork(); | |
| if ($pid == -1) { | |
| die('could not fork a child -- something is wrong'); | |
| } else if ($pid) { | |
| // we are the parent. Nothing to do here, so just wrap back around the loop | |
| } else { | |
| // we are the child. Run the function | |
| run_function($name, $params); | |
| } | |
| } else { | |
| // We don't have pcntl, so just run in process | |
| run_function($name, $params); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment