PDA

View Full Version : timer callback greater than 2 power 31



sriky27
17th March 2009, 13:11
Hi,

How to request a callback greater than the maximum limit of int datatype, is it possible to get a callback at a given time, for example
QDateTime dateTime;
dateTime = dateTime.toLocalTime ();
dateTime.addDays(31);

Now I want to request a callback at set dateTime i.e after 31 days. Is there any api. Please advise.

-Srikanth

sriky27
18th March 2009, 11:04
Hi Experts,

Please give me some suggestion how to proceed. If my question is not clear let me know.
My question is simple QTimer::start(int ) takes integer now I want to get a callback for a interval greater than what integer could take( I presumed that integer is 32 bits). Is there any alternative to get the timer event. Is there any other way to request the timer server. Any custom ways which could be derived and overridden let me know please.

-Srikanth

^NyAw^
18th March 2009, 11:24
Hi,

I think that you can use a QTimer to fire up to 49 days:
The QTimer needs miliseconds

2^32 = 4294967296 maximum miliseconds
4294967296 / 1000 = 4294967,296 seconds
4294967 / 60 = 71582,7882 minutes
71582,7882 / 60 = 1193,04 hours
1193,04 / 24 = 49,7 days

It is not enough you can also fire the timer every day and when it's fired you can use a counter to check if "days" have been passed.

sriky27
18th March 2009, 11:53
Hi,

Yes you are correct but I was looking timer event callback for specific date, like for example a reminder or an anniversary notification to be popped up. Actually I need it because
the Qtimer::start(int) is limited on s60 as the internal timer class takes int microseconds as input so you cannot feed maximum of int in the start as what ever is fed is multiplied 1000 to make it to microseconds

for example you want 32 seconds you feed
QTimer::start(32*1000);

internally it becomes
32*1000*1000.

now if you feed max of integer which is 2 ^ 31 = 2147483648;

internally it become 2147483648*1000 signed integer overflows.

So I need a different mechanism where I could request the timer server give me a callback at the specific time, so that I could avoid this problem.

-Srikanth

^NyAw^
18th March 2009, 11:57
Hi,

Create a timer fired every second and compare dates there.