I think derick does something like this in SRM,
but basically if you want to load something in the global thread, and let the children inherit the data / classes /function etc.
AFAIR you need to serialize the opcodes, and copy them for each thread. (or use something like bcompiler to load cached opcodes for you..)


Basically the engine does thread saftey by having a seperate data store for each thread. As far as the engine goes, it treats each thread pretty much as a seperate process.. There was some code in the threads extension to pass variables between threads.., cant remember the status of it though.

The code I posted works pretty well, but I include a file as soon as the new thread starts up, and dont have any thread global data at present.

Regards
Alan


Bob Beaty wrote:

Which is my concern.

I've looked at the code differences, and it appears that this modification works for running different source files through the engine, but I'm concerned about the safety of zend_eval_string() if I initialize the engine in one thread and then try to have several threads calling zend_eval_string() on different strings.

I'm not convinced that simply making the php_embed_module thread-local is going to work either. I'm concerned that the engine was written with the idea that only one thread can be initializing the php_embed_module and making calls to zend_eval_string(). If this is the case, then I'd have to re-write a lot more than php_embed.c to get thread-safety out of the engine.

Or am I on the wrong track?

        Bob


On Feb 28, 2005, at 1:08 PM, Vadka wrote:


On Mon, 28 Feb 2005, Alan Knowles wrote:

these still need tidying up alot, but the do work.
http://docs.akbkhome.com/php_embed.c.txt
http://docs.akbkhome.com/php_embed.h.txt
replace the code in php_embed with them, make sure you compile with the zts enabled, and the macros's are similar to the original embed (use threaded start call at application start up, and thread start /start end within the pthread_start(...callback..) method

Thread safeness is not a problem for a single thread.
The problem is to call user functions from different threads
(tsrm_ls pointed to somewhere in different threads, global vars etc are not protected).

Thanks, Bob ([EMAIL PROTECTED]) The Man from S.P.U.D. We will write no code before it's designed.


-- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to