Hello all,
I am new to C++ programming. I have encountered a problem where in i am supposed to run a counter when the program reaches a particular point and after that the counter just runs parallely to my program and sends interupts when it expires.. How do I implement the parallel thingy.. Any hints will be appreciated.
1) configure a periodic timer using library facilities (e.g. boost.asio). Increment the counter in the callback function that you provide.
2) launch a thread that runs a loop consisting of a sleep_for() call and a counter increment.
3) configure an periodic timer using OS facilities (e.g. POSIX has it) and increment your counter in the timer signal handler
there's probably more.. you said "new to C++", but is it new to asynchronous calls and interthread synchronization as well? If you are, then maybe it's better to do
4) check the current time directly in the code wherever it could potentially be interrupted by the counter.
I will compile in ubuntu. Can u suggest a library which will have multithreading and which is commonly available. I mean since I have to submit the code some where and if I have a very uncommon library which they might not even have hence the worry.
Thanx