-
-
Notifications
You must be signed in to change notification settings - Fork 132
StreamSelectLoop: Timers with very small intervals do not work correctly #48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I'm having trouble with periodic timers with period lesser than 1 (1.0 is ok, 0.999 is not) and StreamSelectLoop (didn't try other loops yet). I'm stopping the loop after 1.5 second. With period set to 1 the timer is executed once. With period set to 0.999 it's executed several thousands times. The suggested fix did not help at all. |
Having a timer executed every microsecond is the first mistake. What's the purpose of that timer? Apart from that I'm glad that we have |
I don't want timer executed every microsecond, just every half-second or so - for faster tests execution. But instead of being executed twice in one second it is executed like 3000 times. Also how can I use the |
@enumag Amp will support it in version 2.0.0, currently in development. @WyriHaximus started to build an adapter for React as well. |
@clue, hi! Do you have any idea about how to test this thing? I stuck with the same problem as @joshdifabio in #49 – it's hard to test that this feature is working. We need to run timer with very-very small interval and loop's time cost itself is much more expensive and takes much more time than |
Fixed in #93 |
Uh oh!
There was an error while loading. Please reload this page.
Within
StreamSelectLoop::run()
is the following code:In the case of a periodic timer with an interval equal to
Timer::MIN_INTERVAL
(0.000001), the above code, in conjunction with theTimers
class, essentially does something like the following:$timeout
is then passed tostream_select()
andusleep()
, both of which expectint
and so cast(float)0.95
to(int)0
, not waiting at all when the timer was intended to delay for 1 microsecond. Furthermore, the fix in #37 is bypassed when this issue occurs as(float)0.95
casts to booleantrue
.A quick fix would be to apply rounding to
$timeout *= self::MICROSECONDS_PER_SECOND;
.[1] https://3v4l.org/FvioX
The text was updated successfully, but these errors were encountered: