Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ MUSHclient
➜ Suggestions
➜ Timer resolution in milliseconds
Timer resolution in milliseconds
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Kahenraz
(75 posts) Bio
|
Date
| Wed 05 Oct 2016 10:36 PM (UTC) |
Message
| It would be nice to be able to create timers with resolution in the milliseconds. This would be useful for one-off timers to go off in the future rather than perform a busy loop in Lua which locks up the client. | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #1 on Thu 06 Oct 2016 04:29 AM (UTC) |
Message
| The underlying messages from the operating system don't have that granularity. This isn't a real-time game client. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Kahenraz
(75 posts) Bio
|
Date
| Reply #2 on Thu 06 Oct 2016 05:56 AM (UTC) |
Message
| What are you using to create a timer? Win32 SetTimer() has millisecond granularity. | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #3 on Thu 06 Oct 2016 06:23 AM (UTC) |
Message
| Yes, I use SetTimer.
https://github.com/nickgammon/mushclient/blob/master/mainfrm.cpp#L394
But here's the thing ... there is a difference between precision and accuracy. You can specify millisecond precision. But accuracy?
See: WM_TIMER message
When the timer expires you get a WM_TIMER message. From that page:
Quote:
The WM_TIMER message is a low-priority message. The GetMessage and PeekMessage functions post this message only when no other higher-priority messages are in the thread's message queue.
So, you can put in a request that you get a message after 10 milliseconds. But if the Windows message queue is full of incoming data from the MUD, you might wait 10 seconds! |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Kahenraz
(75 posts) Bio
|
Date
| Reply #4 on Thu 06 Oct 2016 06:37 AM (UTC) Amended on Thu 06 Oct 2016 06:38 AM (UTC) by Kahenraz
|
Message
| There's no guarantee that any timer will fire at the expected time. But there is a big difference between 500ms and 1s which shouldn't be an issue.
Timers aren't great for my use case in general but it's the closest thing available to a scheduler and would still be better than halting the client on a busy wait. Providing perceived accuracy in the milliseconds would go a long way. | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #5 on Thu 06 Oct 2016 08:34 AM (UTC) |
Message
| The timer already has a resolution of 0.1 seconds. That is 100 ms. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
20,550 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top