note 103831 added to function.time-sleep-until

From: Date: Thu, 05 May 2011 18:04:28 +0000
Subject: note 103831 added to function.time-sleep-until
Groups: php.notes 
Request: Send a blank email to php-notes+get-179466@lists.php.net to get a copy of this message
At least on my Windows machine, the time_sleep_until function appears to calculate the number of microseconds between now and the sleep-until timestamp, and it appears to use unsigned 32-bit math in this calculation. This roundoff leads to a maximum sleep time of just under 4295 seconds (1 hour, 11 minutes, 35 seconds). To get longer sleep times, while still using time_sleep_until to minimize processor overhead, the following loop may be some help to you: <?php $sleepuntil = strtotime("tuesday 3pm"); while (time() < $sleepuntil) time_sleep_until($sleepuntil); // proceed with dated processing ?> Of course, one could use something like "cron" instead, to avoid the script doing the extended sleep. Also note that time_nanosleep appears to do similar math, but it is somewhat more intuitive that the seconds parameter has an upper limit on what it can be. Still, both functions might report a warning when waking up prematurely due to roundoff. ---- Server IP: 192.41.42.26 Probable Submitter: 174.97.222.160 ---- Manual Page -- http://www.php.net/manual/en/function.time-sleep-until.php Edit -- https://master.php.net/note/edit/103831 Del: integrated -- https://master.php.net/note/delete/103831/integrated Del: useless -- https://master.php.net/note/delete/103831/useless Del: bad code -- https://master.php.net/note/delete/103831/bad+code Del: spam -- https://master.php.net/note/delete/103831/spam Del: non-english -- https://master.php.net/note/delete/103831/non-english Del: in docs -- https://master.php.net/note/delete/103831/in+docs Del: other reasons-- https://master.php.net/note/delete/103831 Reject -- https://master.php.net/note/reject/103831 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#179466) next »