> 2020年8月11日 下午6:39,Dan Ackroyd <dan...@basereality.com> 写道:
> 
> 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
> 
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: https://www.php.net/unsub.php
> 
> 

+1

I would rather have a new function like this (actually I am using it on my 
project):

```
function msleep(int $milli_seconds) { }
```

int is always a better choice than float, otherwise, we have to do dirty 
conversions and more checks on it
And usually, we don't need high precision, millisecond sleep is enough, e.g. 
the timeout feature provided by epoll, it is the reason why many async 
libraries provide timeout feature in milliseconds.


Regards,
Twosee

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php

Reply via email to