Re: threads package status
| From: | Wez Furlong | Date: | Mon, 19 Jul 2004 23:50:45 +0000 |
| Subject: | Re: threads package status | ||
| References: | 1 2 3 4 5 6 | Groups: | php.pecl.dev |
| Request: | Send a blank email to pecl-dev+get-993@lists.php.net to get a copy of this message | ||
proc_open()
stream_select()
No forks, no threads; you don't really need them.
Have a master process spawn a number of worker processes via
proc_open(), creating pipes to each.
Each worker waits for a packet to come in on its stdin pipe, does some
processing and then writes to stdout that it is complete.
Master listens to stdout of all processes to collect the results (it
can also manage "RPC" in this way and feed more data to a particular
process), and then assign jobs to ready workers by stream_select()ing
on their stdin pipes.
Best thing about this technique is that it is portable to OS's that
don't have fork(), and works in non-threaded builds of PHP.
--Wez.