Click here to Skip to main content
15,887,939 members
Articles / Programming Languages / C++11

C++ std::thread Event Loop with Message Queue and Timer

Rate me:
Please Sign up or sign in to vote.
4.78/5 (41 votes)
13 Sep 2020CPOL4 min read 183.6K   4.4K   62  
Create a worker thread with an event loop, message queue and a timer using the C++11 thread support library
std::thread is available to spin off a thread but there is no thread-safe queue and no timers – services that most OS’s provide. In this article I’ll show how to use the C++ Standard Library to create these “missing” features and provide an event processing loop familiar to many programmers.

Views

Daily Counts

Downloads

Weekly Counts

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
United States United States
I've been a professional software engineer for over 20 years. When not writing code, I enjoy spending time with the family, camping and riding motorcycles around Southern California.

Comments and Discussions