Windows Threads
| From: | Markus Duft | Date: | Fri, 09 Sep 2005 08:37:57 +0000 |
| Subject: | Windows Threads | ||
| Groups: | php.pecl.dev | ||
| Request: | Send a blank email to pecl-dev+get-2879@lists.php.net to get a copy of this message | ||
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