Re: Windows Threads
| From: | Alan Knowles | Date: | Fri, 09 Sep 2005 09:18:05 +0000 |
| Subject: | Re: Windows Threads | ||
| References: | 1 | Groups: | php.pecl.dev |
| Request: | Send a blank email to pecl-dev+get-2880@lists.php.net to get a copy of this message | ||
The opcodes are not safe to access from multiple threads, which is part
of the reason we stopped working on the threads extension.
the threads extension uses thread_include - to basically start a new php
process with a fresh set of opcodes...... - this was really the only
simple way to implement a threads extension.
The only other way around it would be to duplicate the current opcodes
(think apc/bcompiler) and make them available to the second thread.. -
but obviously things like the current stack / existing variable are
going to be even more complex to pass around..
Regards
Alan
On Fri, 2005-09-09 at 10:37 +0200, Markus Duft wrote:
> Hi Everybody!
>
> I'm currently trying to implement some threading for my windows API extension, but i got
> some problems and questions:
>
> I want the script to look something like this:
>
> //Extension code:
>
> class xThread
> {
> function __construct($parameters)
> {
> //Just dummys ;o)
> DoSomeWin32StuffInC();
> StartANewThread(array($this, "run"), $parameters);
> }
>
> function __destruct()
> {
> KillTheThread();
> }
>
> abstract function run($parameters)
> {
> //Abstract
> }
> }
>
> PHP code:
> class MyThread extends xThread
> {
> function run($parameters)
> {
> DoSomethingInPHP();
> echo $parameters;
> }
> }
>
> $test = new MyThread("Hello Thread");
>
> OK... My Problems are now: I've got a little function which represents the new thread (in
> C) and does nothing other than calling the $this->run method. But when rtying to call the
> function php crashes. Seems like i'm doing things really wrong. I looked at the pecl threads
> extension, and saw that i would obviously need a php_request_startup() but that didn't change
> anything.
>
> Seems like the script is not available in the new thread, if i see things right. Can i somehow
> copy things over to the new thread, or is this impossible.
>
> Is there any chance to get a method called from the new thread or is the object invalid if i
> pass it to a new thread (the this_ptr)?
>
> Creating, ending and terminating the thread is no problem. Just calling PHP is ;o(
>
> Any ideads?
>
> Thanks in Advance,
> Markus