timers in C++

Discussion in 'C++' started by solarin, Aug 23, 2006.

  1. solarin

    solarin Guest

    Im devoloping a simulator for a driver. Every time the simulator
    recieves a frame, it must answer with another. One of these frames,
    forces to use a few variables during 3 seconds. How I should create a 3
    seconds timer? During this time , the simulator and the driver continue
    receiving and sending data of course.

    Thanks for your support.
    solarin, Aug 23, 2006
    #1
    1. Advertising

  2. solarin

    Jaime Guest

    If your C++ program will run on Unix/Linux, you can use setitimer in
    <sys/time.h>
    It can be consulted with "man setitimer" on the command line.
    Jaime, Aug 23, 2006
    #2
    1. Advertising

  3. solarin

    solarin Guest

    Jaime ha escrito:

    > If your C++ program will run on Unix/Linux, you can use setitimer in
    > <sys/time.h>
    > It can be consulted with "man setitimer" on the command line.


    Im developing under windows, but thanks for your help.
    solarin, Aug 23, 2006
    #3
  4. solarin

    Howard Guest

    "solarin" <> wrote in message
    news:...
    >
    > Jaime ha escrito:
    >
    >> If your C++ program will run on Unix/Linux, you can use setitimer in
    >> <sys/time.h>
    >> It can be consulted with "man setitimer" on the command line.

    >
    > Im developing under windows, but thanks for your help.
    >


    You'll need to ask in a Windows newsgroup then. Timers are not part of the
    C++ language itself, but are supplied by the operating system (and sometimes
    wrapped by compiler or third-party vendors, I suppose).

    -Howard
    Howard, Aug 23, 2006
    #4
  5. solarin

    Moonlit Guest

    Hi,

    One solution is to use mutlithreading. Lookup beginthreadex, mutexes
    WaitForSingleObject etc.

    Another solution. When reading from file descriptors sockets you can
    use(/abuse) 'select'. The last parameter of select is a timeout value i,e.

    Set the timeout to 3 seconds.
    If anything is received on the descriptors check the time (you can do
    precision timing with the multimedia functions of windows) So you know how
    long the next wait should be
    Handle the incoming messages
    Do an select of the remaining 3 seconds (you can check the return value of
    select to know if it returned because of timer expiry)

    If return because of 3 second elapse do your '3 second thing'

    Ad infinitum

    --


    Regards, Ron AF Greve

    http://moonlit.xs4all.nl

    "solarin" <> wrote in message
    news:...
    > Im devoloping a simulator for a driver. Every time the simulator
    > recieves a frame, it must answer with another. One of these frames,
    > forces to use a few variables during 3 seconds. How I should create a 3
    > seconds timer? During this time , the simulator and the driver continue
    > receiving and sending data of course.
    >
    > Thanks for your support.
    >
    Moonlit, Aug 23, 2006
    #5
  6. solarin

    Default User Guest

    Moonlit wrote:

    > Hi,


    Please don't top-post. Your replies belong following or interspersed
    with properly trimmed quotes. See the majority of other posts in the
    newsgroup, or the group FAQ list:
    <http://www.parashift.com/c++-faq-lite/how-to-post.html>



    Brian (synchronicity -- Laura Nyro's "Timer" is playing)
    Default User, Aug 23, 2006
    #6
  7. solarin

    Boris Guest

    solarin wrote:
    > Im devoloping a simulator for a driver. Every time the simulator
    > recieves a frame, it must answer with another. One of these frames,
    > forces to use a few variables during 3 seconds. How I should create a
    > 3 seconds timer? During this time , the simulator and the driver
    > continue receiving and sending data of course.


    There are some timer classes in Boost:
    http://www.boost.org/libs/timer/index.html
    I never tried them though.

    Boris
    Boris, Aug 23, 2006
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Stephen Inkpen

    Timers in application web programming

    Stephen Inkpen, Jul 16, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    330
    Ken Cox [Microsoft MVP]
    Jul 16, 2003
  2. Kelsang Wangchuk

    System.Timers.Timer vs. System.Threading.Timer

    Kelsang Wangchuk, Jul 31, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    702
    Kelsang Wangchuk
    Jul 31, 2003
  3. Girish Pal Singh

    timers

    Girish Pal Singh, Aug 11, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    558
    Kevin Spencer
    Aug 11, 2003
  4. Girish Pal Singh

    Web Timers

    Girish Pal Singh, Aug 13, 2003, in forum: ASP .Net
    Replies:
    4
    Views:
    435
    George Ter-Saakov
    Aug 13, 2003
  5. Steve C. Orr [MVP, MCSD]

    Re: timers

    Steve C. Orr [MVP, MCSD], Dec 8, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    386
    Steve C. Orr [MVP, MCSD]
    Dec 8, 2003
Loading...

Share This Page