Re: Allow sleep() to accept non-integer values
| From: | Michael Voříšek - ČVUT FEL | Date: | Thu, 20 Aug 2020 12:15:30 +0000 |
| Subject: | Re: Allow sleep() to accept non-integer values | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-111650@lists.php.net to get a copy of this message | ||
Hi everyone,
thank you for your comments, based on them, I fixed these:
- usleep is now used as a fallback as well, if interrupted, remaining
time is measured using microtime, so return value is always available
- for BC, if not interrupted, return value remains to be 0 (integer
zero)
Now, the sleep() function should be really universal, cross platform and
I would say also the prefered way to sleep.
The implementaion is here https://github.com/php/php-src/pull/5961/files
Please comment on Github directly if you have any feedback left.
I thinkit's worth considering if this also should be fixed in 8.0 or even earlier ;-)So good to hear the RM view on this.Sara, are you ok to include this in PHP 8.0 and do you require a RFC for it? With kind regards / Mit freundlichen Grüßen / S přátelským pozdravem, Michael Voříšek On 11 Aug 2020 12:43, Björn Larsson wrote:
Den 2020-08-11 kl. 10:53, skrev Rowan Tommins: On Tue, 11 Aug 2020 at 08:31, Michael Voříšek - ČVUT FEL < vorismi3@fel.cvut.cz> wrote: I am the author of https://github.com/php/php-src/pull/5961 , please provide feedback. This idea makes a lot of sense to me as a user (I'll leave comments on the implementation to those with more C experience). I'm pretty sure I've accidentally written things like "sleep(1.5)" in the past, and think there is a strong argument for changing something here: Another reason is that sleep(0.1); is silently accepted now (even with strict types enabled), but the input is casted to 0 and thus producing unexpected behaviour if the user is not aware of the current method prototype. Unless there are problems with the implementation, this seems like a straight-forward win. Regards,Given this unexpected behaviour, one could almost see it as a bug. I think it's worth considering if this also should be fixed in 8.0 or even earlier ;-) So good to hear the RM view on this. r//Björn L