Closed bimbiman closed 9 years ago
ive tested it on 5.5,5.6 86 and 64bit.
and it seems that worker object in work like a black hole - when try to execute worker fucntion ($this->worker->foo()), or just var_dump($this->worker) or even var_dump($this) (where worker object is), script just OUTPUT NOTHING. Real buggy on windows 2012 server. so for keep working, i had to transfer all functions from worker to work and use worker just like class Bla_bla extends Worker{} for declareting Pool for example
Seems its STACKABLE problem.
class StackableArray extends Stackable { public function run() {} } class T extends Thread { public function __construct($test){ $this->test = $test; $this->start(); } public function run(){ $this->test[]=rand(1,2); -------------------- FAILLLLL return true; } $test=new StackableArray(); foreach($qs as $q){ $ts[]=new T($test); }
AND IF public function __construct($test){ $this->test = $test; var_dump($this->test); - we could see it. but if thread start - we lost it. //$this->start(); }
Sorry about the delay.
Please provide reproducing code for the bug.
I'll get to it as quick as I can, again sorry about the delay.
No problem. Anyway thx for php multithreading. And we all also know that ur busy. So, just try ur examples Pooling.php StackableArray.php SQLWorker.php
on windows server 2012. and u will see. any 32\64bit php 5.3-5.6 ts.
We have this bug too. If you pass not StackableArray instanse to thread you can access to it in "run" method. Otherwise it fails.
i dont know about 7 (if u mean server version), becouse in win7 64bit pro - all ok.
also i detect that on windows sometimes in highload scripts with 100-200 threads after finish CLI process dont quit. i dont know why. max_exec time not working. seems its Windows buggy. But its not fatal, becouse you can kill process by "timeout".
but StackableArray in win server - really problem =(
Excuse me... We tried it on Windows 8 64, php 32 bit Windows 7 64, php 32 bit. It works fine! It seems trouble in php. Trouble on Win8 64 with php 64 bit.
<?php
function println($text)
{
echo $text . PHP_EOL;
}
class ATest extends Stackable
{
private $a;
public function __construct($a = 0)
{
$this->a = $a;
}
public function hello()
{
println(sprintf("Hello World #%d", $this->a++));
}
}
class Test extends Thread
{
private $test;
public function __construct(ATest $test)
{
$this->test = $test;
}
public function run()
{
$this->test->hello();
}
}
$test = new ATest;
$thread = new Test($test);
$thread->start();
$thread->join();
$test->hello();
Please can someone confirm if this is still present ?
i will test it today again.
Thanks :)
poke @bimbiman :)
1 moment ;] testing 5.5 and 5.6 with latest version
in win8\windows server 2012 64bit + 64bit php doesnt work pooling.php from examples and next test script:
<?php
class MegaTask extends Stackable {
public function __construct($i){
$this->i = $i;
}
public function run(){
$this->worker->foo1($this->i);
$this->complete = true;
}
public function isComplete() {
return $this->complete;
}
protected $complete;
}
class WebWorker extends Worker {
public function foo1($a){
echo $a;
}
}
$pool = new Pool(10, \WebWorker::class);
for($i=0; $i < 10; $i++){
$pool->submit(new MegaTask($i));
}
$pool->shutdown();
$pool->collect(function($work){
return $work->isComplete();
});
?>
->worker->foo1 - isnt work. $this->worker Like black hole
Is this with 2.0.9 ?
Sorry, windows releases are built when pecl releases are done and 2.0.9 is master today, will do a release today or tomorrow.
i will test it today\tomorrow
Closing, if this still exists in PHP7, open a new issue ;)
there is no $this->worker in work object on windows server 2012