My program has an event loop disciplined by
(for I/O) and condition variables (for other message activity), as well as a worker thread responsible for catching signals (
are blocked in all other threads.
calls have a 500ms timeout, but I am trying to reduce context switches and use an infinite
instead, woken by pipe activity when the main thread decides it's time to quit the program and the event loop should be stopped.
call has a 500ms timeout (and checks a
after each call, to see whether it needs to stop), and I'd like to replace this with something that doesn't need to keep waking to check for interruption.
Can I raise a signal from the main thread to the signal-watching thread to achieve this, or something like that? Or is there a better way to catch signals in this day and age?
This is on CentOS 6 and 7 (though a general POSIX solution would be preferred — bonus points for mere standard C++11!).