We have a multi-threaded C++ app which is mis-behaving. Fixing a corner-case bug properly would likely be a lot of work. Putting a patch on a bullet wound in combination with something else might do the trick. Due to too many heavy (GUI) threads being spawned, we are running over the limit of messages, which is defined in:
HKLM\Software\Microsoft\Windows NT\CurrentVersion\Windows\USERPostMessageLimit
- currently set at 10,000
.
One idea for a hack would be to postpone creating new threads when the queue is ... say 75%
full. I am hoping that it is possible to sample the queue utilization, say once per second, and decide whether any new threads should be allowed.
As crappy as this sounds, it does solve the problem of picking the right constant threshold, or trying to adjust it based on hardware profile.
C++ code samples to do this, and/or out-of-the-box suggestions are welcome. Thanks!