note 69109 added to function.usleep
| From: | RasmusSchultz at osu1 dot php dot net | Date: | Wed, 23 Aug 2006 13:39:51 +0000 |
| Subject: | note 69109 added to function.usleep | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-116225@lists.php.net to get a copy of this message | ||
I have spent DAYS trying to create a reliable usleep()-replacement for Windows.
I have only this to offer:
As commented by someone else already, the gettimeofday() method used below is useless - PHP will use
all available CPU power doing nothing.
The fsockopen() method apparently is also useless - as someone else commented, an fclose() was
missing in the original post, but this apparently does not solve the problem. After calling the
function about 50 or so times, fsockopen() returns immidiately, without any delay - and watching a
process monitor in Windows, you can then watch the process taking up increasingly more memory, until
eventually PHP aborts (or crashes) when it reaches maximum.
The win32api-method is also a no-go ... after calling the Sleep function a few hundred times (during
which memory usage will also go up every time due to a memory leak somewhere), PHP will cause an
exception and Windows will terminate it.
I have given up - I don't think there is any viable solution to this problem under PHP 4.
If you need this function, upgrade your project to PHP 5.
Or settle for 1-second delays with the sleep()-function.
These, unfortunately, seem to be your only options...
----
Server IP: 195.184.96.15
Probable Submitter: 82.143.224.4
----
X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER
autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/function.usleep.php
Edit -- https://master.php.net/note/edit/69109
Del: integrated -- https://master.php.net/note/delete/69109/integrated
Del: useless -- https://master.php.net/note/delete/69109/useless
Del: bad code -- https://master.php.net/note/delete/69109/bad+code
Del: spam -- https://master.php.net/note/delete/69109/spam
Del: non-english -- https://master.php.net/note/delete/69109/non-english
Del: in docs -- https://master.php.net/note/delete/69109/in+docs
Del: other reasons-- https://master.php.net/note/delete/69109
Reject -- https://master.php.net/note/reject/69109
Search -- https://master.php.net/manage/user-notes.php