![]() Higher level things such as grouping handlers in one timer and timers that can be reused (like boost Asio’s own implementation), can be built on top. What I explore in this post is a Timer Queue implementation. Win32 API uses the same name for such a thing: Timer Queues So, how do we go about implementing timers?Īt its core, you need a queue for the timers, and a worker thread that dequeues and executes timers according to the specified expiry times/dates. Certainly it can, but can be used for a lot more.įor simplicity, I’ll be calling it “timer(s)”, and not “deadline timer(s)” A bit of brainstorming With the definition of “deadline” being “ the latest time or date by which something should be completed“, the first thing that crosses my mind is that it is used to cancel some operation that did not complete by the specified time/date. I think the “deadline” in deadline_timer is a bit misleading. ![]() If I had to roughly describe what deadline_timer is for while at the same time hinting at the implementation, I would say “ deadline_timer allows you group together a bunch of handlers to be called when a timer expires“. The implementation shown here is custom made, portable C++11 and self contained. This time around, I’m going to focus on the equivalent of boost::timer::deadline_timer. Also covered strands, and why they are such a nice concept. I covered what I called callstack markers, which has more uses than it looks on the surface. If you looked at my previous posts, you noticed I explored some of the nice things Boost Asio gives you, and how I implemented my own version.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |