The problem you are describing requires a real-time scheduler and synchronizer. Although I understand that such things exist in the Windows API, I tried very hard not to know about them.
My recommendation, if the rest of the system is not a real-time system, should minimize your own decision using the priority queue. Make sure that each thread transfers its effective priority to the queue during registration, blocks this thread on condvar and organizes it so that when an event occurs, it is delivered only to the first thread in the queue.
There will probably be a bit of an ugly hack, but if the number of threads is small, you can make some brute force with one conduit in the waiting thread and make it work.
Depending on what you need, consider the following: each recipient event stream has an associated event queue (maybe this is really a mailbox, a queue with 1 depth) with a mutex and a converter. When threads are registered to receive an event, they are added to the priority queue, as described above, and then blocked. When an event occurs, the event delivery thread selects the queue member with the highest priority, deletes it, sends an event notification to a separate thread event queue, waking up the thread.
andersoj
source share