I want to create a timer which ticks after I run my program.
this timer should call one of my functions in 10 or 100 milliseconds.
I have some info about time.h but I think it is not compatible to my requirements. So if someone gives me a clue what I should do first hand, I ll be glad.
You're trying to measure how long something takes to execute? In that case, ctime will work perfectly. Create your own macro for clock ticks per millisecond, create a clock object for your start, one for your end, get the number of clock ticks since your program started upon starting of your timer, then get the number of clock ticks since your program started upon the ending of your timer, and take the difference.
If you're trying to set a delay, then ctime would work but it's a waste of resources. Use (on UNIX) usleep(milliseconds) or (on Windows) Sleep(milliseconds).
I am trying to put a timer to my code which triggers a function I already coded in some interval(10 ms or 100 ms). Your approach seems good but I need to optimize it as well so I search some and find out ACE Frame work has some timers. In my project I use ACE as well. I am reading to how to implement one of these timers to my code. If I feel your approach is better I ll do that:)
In this thread, I wrote a mock-up of a timed callback in C++. Unfortunately, the time was not very accurate. Consider my approach but with a different underlying timer: http://www.cplusplus.com/forum/beginner/23636/
Note that my approach is extensible, as apposed to the other suggested solutions.