Results 1 to 5 of 5

Thread: timer callback greater than 2 power 31

  1. #1
    Join Date
    Mar 2009
    Posts
    19
    Qt products
    Qt4
    Platforms
    Windows

    Default timer callback greater than 2 power 31

    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

  2. #2
    Join Date
    Mar 2009
    Posts
    19
    Qt products
    Qt4
    Platforms
    Windows

    Question Re: timer callback greater than 2 power 31

    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

  3. #3
    Join Date
    Jan 2006
    Location
    Sta. Eugènia de Berga (Vic - Barcelona - Spain)
    Posts
    869
    Thanks
    70
    Thanked 59 Times in 57 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Angry Re: timer callback greater than 2 power 31

    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.
    Òscar Llarch i Galán

  4. #4
    Join Date
    Mar 2009
    Posts
    19
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: timer callback greater than 2 power 31

    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

  5. #5
    Join Date
    Jan 2006
    Location
    Sta. Eugènia de Berga (Vic - Barcelona - Spain)
    Posts
    869
    Thanks
    70
    Thanked 59 Times in 57 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: timer callback greater than 2 power 31

    Hi,

    Create a timer fired every second and compare dates there.
    Òscar Llarch i Galán

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.