In single-threaded apps, especially in C, I've always used wrappers for select() that maintain a priority heap of timers to call in the future, and arrays of file descriptors to monitor for readability, writability, and exceptions. The X-Windows library Xt has a "Event Loop" inside XtAppMainLoop() that does exactly this.
In multi-threaded apps, with say dozens of peer processes to communicate with, and hundreds or thousands of timer events registered to go off in the future, what approaches are often used, besides using the single-threaded solution select() (or its higher-performance equivalents like epoll()) in a multi-threaded context?
The question is mostly for C++11 and newer, on Linux, but if there are Microsoft-specific solutions I'd like to get a general feel for them too.
Aucun commentaire:
Enregistrer un commentaire