Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > timers in C++

Reply
Thread Tools

timers in C++

 
 
solarin
Guest
Posts: n/a
 
      08-23-2006
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.

 
Reply With Quote
 
 
 
 
Jaime
Guest
Posts: n/a
 
      08-23-2006
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.

 
Reply With Quote
 
 
 
 
solarin
Guest
Posts: n/a
 
      08-23-2006

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.

 
Reply With Quote
 
Howard
Guest
Posts: n/a
 
      08-23-2006

"solarin" <> wrote in message
news: oups.com...
>
> 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


 
Reply With Quote
 
Moonlit
Guest
Posts: n/a
 
      08-23-2006
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: oups.com...
> 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.
>



 
Reply With Quote
 
Default User
Guest
Posts: n/a
 
      08-23-2006
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)
 
Reply With Quote
 
Boris
Guest
Posts: n/a
 
      08-23-2006
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


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Timers spf R Siffredi Cisco 1 10-31-2005 05:11 PM
Web Timers Girish Pal Singh ASP .Net 4 08-13-2003 08:59 PM
timers Girish Pal Singh ASP .Net 2 08-11-2003 01:00 PM
System.Timers.Timer vs. System.Threading.Timer Kelsang Wangchuk ASP .Net 0 07-31-2003 04:28 PM
Timers in application web programming Stephen Inkpen ASP .Net 1 07-16-2003 02:12 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57