|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2014-01-06 03:52 UTC] alan_k@php.net
-Package: threads
+Package: pthreads
[2014-01-06 03:52 UTC] alan_k@php.net
[2014-01-06 08:05 UTC] krakjoe@php.net
-Status: Open
+Status: Not a bug
[2014-01-06 08:05 UTC] krakjoe@php.net
[2014-01-11 18:06 UTC] post-christian at freenet dot de
[2014-01-11 18:39 UTC] krakjoe@php.net
[2014-01-12 05:42 UTC] post-christian at freenet dot de
[2014-01-12 06:16 UTC] post-christian at freenet dot de
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 01 00:00:01 2025 UTC |
Description: ------------ The test script below works with timeouts of 10ms or 1sec, but doesn't work with timeouts of 100ms or 500ms, Cond::wait returns much faster then expected. Test script: --------------- class Test extends Thread { private $mutex, $cond; public function __construct() { $this->mutex = Mutex::create( true ); $this->cond = Cond::create(); } public function __destruct() { Cond::destroy( $this->cond ); Mutex::unlock( $this->mutex ); Mutex::destroy( $this->mutex ); } public function run() { while( true ) { trace( "test", "running" ); if( @ Cond::wait( $this->cond, $this->mutex, 500000 ) ) break; } echo "stopped\n"; } public function stop() { Cond::signal( $this->cond ); $this->join(); } } $test = new Test(); $test->start(); sleep( 5 ); $test->stop(); function trace( $sender, $msg ) { $ts = microtime( true ); echo date( 'd/m H:i:s', $ts ), substr( sprintf( "%.6f", $ts - (int) $ts ), 1 ), ' ', $sender, ': ', $msg, "\n"; } Expected result: ---------------- Waiting for the given timeout. Actual result: -------------- Seems to return immediately but much faster from Cond::wait with some timeouts.