I have code that sends notifications from thread A to thread B. Works fine… generally.
However - some of the code in thread A is in quite tight/fast loops, so it often happens that MANY notifications a second are sent to thread B. It seems as if some get lost, i.e. thread B’s code does not detect some of them (even with the LIFO nature kept in mind).
If I (experimentally) build delays into thread A’s loops to slow it down somewhat, thread B receives them all again.
Maybe you’re pushing the notification paradigm more than most folks do?
Are you doing a lot of work in the NOTIFICATION event?
I wonder if queueing up the notifications (in a queue), and processing them in another event would help any.
Your loop is hogging all the resources and not letting other parts of the runtime or os run properly.
Yield only works on intel cpus with hyperthreading switched on, sleep is an option at the end of the loop.
This thread [1] can shed some light, but I cant find the windows apis that handle notification, google keeps giving me the toaster notification api’s.
One other option is go back to the cooperative threadibg model ie <c6 threading model, but you wont have notify to use.
You could post code to help us not guess possibilities, but another trick would be to go into control panel, system icon, select advanced system settings, advanced tab, performance settings button, advances tab, select background services if not already, click ok then reboot. That takes cpu time away from your loop and lets other parts of windows and other apps get more cpu time. This might help your two threads, but it depends on how sv have implementated notify in the runtime.
[1]
Edit. As there is a good chance these two threads are running on seperate cores, another trick you could try is bind your app to one cpu core as well.
I think Dries did a global ext template that did this for you. Thats worth a try, but if lots of work, the cpu might clock back its speed to handle one core getting too hot. Ymmv.
I also dont know if windows alters cpu scheduling or gives more cpu time to the other cores to balance the temperatures across cores. That would be a nice feature if windows did that!