Current scenario is epoll_wait over a couple of fds and a queue of possible incoming messages, I'd like the loop below epoll_wait to be executed on IO event or on new message.
Ways I know:
- Use a
time
msec timeout and check the queue first thing in the loop - Use the self-pipe trick from the queue code when messages become available
- Interrupt the syscall with a standard signal
- Use epoll_pwait and refine the previous point
None of the points posted above satisfy me enough and I was wondering if there are any other methods that I haven't found.
Reasons are:
- Signals are something to avoid on multithreaded code and are not very reliable
- Timeout one removes part of the benefit of the epoll, only waking with events
- Self-pipe trick looks the best approach for the moment, but still too much boilerplate
ideas?