C ++ 11 method for creating an event loop

What is the main structure of the event loop system in C ++ 11? How are key elements (such as message queue, message manager, signal) implemented? For example, do I still need std::queue<Message> , a std::mutex and a std::condition_variable like what I did in C ++ 98 + boost? In addition, performance matters in the solution I'm looking for.

+6
source share
1 answer

Do it in much the same way you would do it in C ++ 98. You can replace some platform-specific things like pthread_t, pthread_mutex and pthread_cond with standardized equivalents (std :: thread, std :: {recursive _,} {timed _,} mutex and std :: condition_variable {, _ any}), but the basic design is the same.

As @beerboy noted, Boost.Asio could be a good place to start, although AFAIK is not yet updated for C ++ 11.

+2
source

Source: https://habr.com/ru/post/945195/


All Articles