I'm trying to use pthreads in PHP in an attempt to speed up a series of calculations that at the moment max out one CPU core for several seconds. I have split the calculations into a number of ranges and am running each range in the parent thread:
$threads = array();
foreach($cp as $c) {
$threads[$c] = new ThreadedMatcher($params);
$threads[$c]->start();
}
I then want to array_merge
the arrays created in each child thread (for each range) in the parent thread to get a value over the whole data set.
I gather that I need to use join()
in the parent thread to wait for a thread to finish but how do I actually get a value out of the child thread into the parent thread?