Sotirios Delimanolis Sotirios Delimanolis - 7 months ago 18
C++ Question

What is the proper way of doing event handling in C++?

I have an application that needs to respond to certain events in the following manner:

void someMethodWithinSomeClass() {
while (true) {
wait for event;
if (event == SomeEvent) {
if (event == SomeOtherEvent) {

This would be running is some thread. In some other threads, operations would create and fire the Events. How do I get these Events to reach the above method/class? What is the proper strategy or architecture for implementing event handling in C++?

Answer Source

The C++ Standard doesn't address events at all. Usually, however, if you need events you are working within a framework that provides them (SDL, Windows, Qt, GNOME, etc.) and ways to wait for, dispatch and use them.

Aside from that, you may want to look at Boost.Signals2.