On Mon, Apr 5, 2010 at 7:17 PM, Alexey Zakhlestin <indey...@gmail.com> wrote: > > On 05.04.2010, at 13:46, Moriyoshi Koizumi wrote: > >> I used to play with TSRM days ago and successfully implemented >> userland threading support using GNU Pth. It's just a proof of >> concept and I did it for fun. > > So these are share-nothing worker-threads, which can send results to > "master-thread" using messages. right? > I am perfectly fine with such approach
A new thread can be created within a sub-thread as well. In addition, messages can be interchanged between any pair of threads. While it is based on shared-nothing approach, some kinds of resources are shared across threads besides classes and functions that would have already been defined before the thread creation. > > some stylistic moments: > * I would use closures instead of callback-functions I was trying hard to make closures work with the extension, but it wouldn't end up with a success. I guess I can fix it somehow. > * Is extra language construct really needed? function-call would work just > fine I don't quite think so. It was just an experiment, and each extra syntactic sugar would get converted to a corresponding single function call (either thread_message_queue_post() or thread_message_queue_poll() .) > Is overhead of starting new thread large? The cost is almost the same as when spawning a new runtime instance on a threaded web server with TSRM enabled. If you'd pass a large data to the subthread, then the overhead should go large because of the deep copy. Moriyoshi -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php