My project is a job server that stores commands received by UDP in a queue. Every command has an interval value to be executed and an timeout value to be removed. These actions are controlled by a timer that must run independent of the server code, like 2 processes.
What’s the best way to make a server and a timer running without blocking each other? I am thinking about threads or asynchronous calls but I’m new to C++ and I don’t know how to apply these ideas in my code.
I’m using Visual C++ 2010 and ASIO from Boost 1.48.
Thanks!
You can schedule an asynchronous (non-blocking)
deadline_timerwith Boost ASIO, as introduced here: http://www.boost.org/doc/libs/1_48_0/doc/html/boost_asio/tutorial/tuttimer2.htmlI assume you are using ASIO for your UDP communication already (since you mentioned both)–now it’s just a matter of scheduling the timers you need in your event loop, and everything should just work.