Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
I'm desperately in need of a way to share objects between threads. I've used shared memory and other methods but I need to be able to pass around more than just value objects. Has anyone looked into writing an extension in php that will allow for the sharing of resource? For ex. I would like to be able to do the following...Code: Select all
// thread1.php
class RandomInt
{
private $int = 0;
public function generate()
{
$this->int = rand(0, 100);
}
public function getInt()
{
return $int;
}
}
$o = new RandomInt();
// our magical function that puts a pointer to the resource (or something) into fairy lang
set_shared_resource('random_int_object', $o);
while (true)
{
$o->generate();
}Code: Select all
// thread2.php
$e = get_shared_resource('random_int_object');
while (true)
{
echo $e->getInt();
}feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]