Re: Allow sleep() to accept non-integer values

From: Date: Tue, 11 Aug 2020 11:03:44 +0000
Subject: Re: Allow sleep() to accept non-integer values
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-111453@lists.php.net to get a copy of this message
Another reason is that sleep(0.1); is silently accepted now (even with strict types enabled), That appears to not be true: https://3v4l.org/7YbqX
corrected, should be "without strict types enabled" - https://3v4l.org/A2olN "even with strict type enabled" statement in BC section remains valid
Having a function that behaves differently based on different platforms is a bad idea.
I will implement fallback to usleep. I have not noticed any issues with usleep availability. Is there any known platform without nanosleep neither usleep support? With kind regards / Mit freundlichen Grüßen / S přátelským pozdravem, Michael Voříšek On 11 Aug 2020 12:39, Dan Ackroyd wrote:
Michael Voříšek wrote:
Another reason is that sleep(0.1); is silently accepted now (even with
strict types enabled), That appears to not be true: https://3v4l.org/7YbqX Rowan wrote:
Unless there are problems with the implementation, this seems like a
straight-forward win. From the PR.
Implemented using nanosleep which is not guaranteed to be available everywhere.
Please just use usleep if you need more accuracy than seconds. Having a function that behaves differently based on different platforms is a bad idea. Changing a function to have surprising behaviour just to avoid using a different function, that is already available, is a really bad tradeoff. cheers Dan Ack


« previous php.internals (#111453) next »