php pthreads: 'PHP Fatal error' , 'Fatal error' in CLI -
i ran example of https://github.com/krakjoe/pthreads/tree/seven/examples
in cli. after executing each one, php fatal error
, fatal error
,in addition expected result. example in case https://github.com/krakjoe/pthreads/blob/seven/examples/closurefuture.php
i'll get:
object(volatile)#6 (2) { [0]=> string(5) "hello" [1]=> string(5) "world" } array(2) { [0]=> string(5) "hello" [1]=> string(5) "world" }
php fatal error: cannot declare class future, because name in use in /var/www/test/index1.php on line 42
fatal error: cannot declare class future, because name in use in /var/www/test/index1.php on line 42
in example error occured when extended class closed.
do know reason of these errors , how correct them? appreciated.
class future extends thread { private function __construct(closure $closure, array $args = []) { $this->closure = $closure; $this->args = $args; } public function run() { $this->synchronized(function() { $this->result = ($this->closure)(...$this->args); $this->notify(); }); } public function getresult() { return $this->synchronized(function(){ while (!$this->result) $this->wait(); return $this->result; }); } public static function of(closure $closure, array $args = []) { $future = new self($closure, $args); $future->start(); return $future; } protected $owner; protected $closure; protected $args; protected $result; }//line 42
check server installed php version. according doc, supporting (php 5 >= 5.3.0).
Comments
Post a Comment