pthreads - Mutex::unlock exiting program in php 5.5.12 with php_pthreads-2.0.9-5.5-ts-vc11-x64 on Windows -



pthreads - Mutex::unlock exiting program in php 5.5.12 with php_pthreads-2.0.9-5.5-ts-vc11-x64 on Windows -

i seem having weird issue when attempting run pthreads in php. i'm attempting utilize threads manage additional calling of other php scripts, programme exiting prematurely, whenever effort utilize mutex::unlock. i've tried re-installing different versions of 64 bit pthreads tested examples (of which, mutex here works ). think may problem popen. has nail error before or know of way debug it?

the code i'm using follows:

<?php class lockedthread extends thread { public function __construct($func, $megalog, $mutex){ $numargs = func_num_args(); $this->megalog = $megalog; $this->func = $func; if ($numargs == 3) { $this->mutex = array($mutex); } else { $arg_list = func_get_args(); $this->mutex = array_slice($arg_list, 2); } } public function run() { echo "beginning " . $this->func . " \n"; ($i = 0; $i < count($this->mutex); $i++) { $locked = mutex::lock($this->mutex[$i]); while($locked == false) { sleep(0.5); $locked = mutex::lock($this->mutex[$i]); } printf($this->getthreadid() . " acquired lock " . $this->mutex[$i] . "\n"); } $this->res = popen("php functions/" . $this->func . ".php" . " >> logs/" . $this->func . ".log", 'r'); printf("closing " . $this->func . ": " . pclose($this->res) . "\n"); ($i = count($this->mutex) - 1; $i >= 0; $i -= 1) { printf($this->getthreadid() . " attempting release lock " . $this->mutex[$i] . "\n"); mutex::unlock($this->mutex[$i]); echo $this->getthreadid() . " released lock " . $this->mutex[$i] . "\n"; } echo "really closing " . $this->func . "\n"; } } } // create mutex. note, connections mutex come first $connmutex = mutex::create(true); $eventmutex = mutex::create(true); $workers["checkrecurrence"] = new lockedthread("checkrecurrence", $megalog, $eventmutex); $workers["checkrecurrence"]->start(); echo "checkrecurrence " . $workers["checkrecurrence"]->getthreadid() . "\n"; $workers["checkdeletion"] = new lockedthread("checkdeletion", $megalog, $eventmutex); $workers["checkdeletion"]->start(); echo "checkdeletion " . $workers["checkdeletion"]->getthreadid() . "\n"; echo "unlocking conn: " . mutex::unlock($connmutex) . "\n"; echo "unlocking event: " . mutex::unlock($eventmutex) . "\n"; foreach($workers $i=>$worker) { echo "joining $i \n"; while ($worker->join() === false) { echo "attempt of $i \n"; } echo "joined $i \n"; } sleep(1); echo "finishing destruction of workers!\n"; /* please remember destroy mutex , status variables */ mutex::destroy($connmutex); mutex::destroy($eventmutex);

the logs i'm getting are:

"c:\wamp\bin\php\php5.5.12\php.exe" "c:\wamp\www\hang\phpautomation\index.php" origin checkrecurrence checkrecurrence 8576 origin checkdeletion checkdeletion 9144 started workers unlocking conn: 1 unlocking event: 1 joining checkrecurrence 8576 acquired lock 52687024 closing checkrecurrence: 0 8576 attempting release lock 52687024 done.

php pthreads mutex

Comments

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -