Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Callbacks and Timers » Time callbacks when ticks overlap
Time callbacks when ticks overlap [message #27554] Fri, 23 July 2010 11:03 Go to previous message
Zbych is currently offline  Zbych
Messages: 325
Registered: July 2009
Senior Member
Hi,

I have a problem with time callbacks. They use GetTickCount which overlaps every ~50 days and do all calculations on 32-bit variables. Unfortunately Ctrl::TimerProc doesn't work correctly when (GetTickCount + delay) overlaps.

For example when GetTickCount returns 0xFFFF0000 and I want to set time callback to 2 minutes (0x1D4C0 ms), TimeEvent.time is set to 0x0000D4C0 and Ctrl::TimerProc executes callback every time (because this statement "list->GetNext()->time < time" is true).
This situation is more likely to happen on posix, because GetTickCount returns ticks since the Epoch, not system power on.

My proposition is to change time comparison:
old:
while(list->GetNext() != list && list->GetNext()->time < time) {

new:
while(list->GetNext() != list && ((int)(time - list->GetNext()->time)) > 0) {


Casting to a signed number is a must.

and to remove this (I think it is unnecessary):
	if(e->time > 0x80000000)
		e->time = 0;

 
Read Message
Read Message
Read Message
Read Message
Previous Topic: Date iterator
Next Topic: how to use timer id? and how to kill a timer
Goto Forum:
  


Current Time: Fri Apr 26 01:32:50 CEST 2024

Total time taken to generate the page: 0.05501 seconds