Ceniza talked with me about this already, but I guess it's worth posting a note for everyone else again
Please do not tamper with any code only to make Valgrind [insert any other analysis tool] happy.(print this in poster size and hang it over your bed)While it is true that Valgrind [iaoat] may help you spot leaks and other errors, it is intrinsically stupid. It knows nothing about the programmer's intent or the program's normal mode of operation.
It may give a hint if you're looking for a problem. It may even give you a hint if you're just profiling the program to "clean up". Those hints may be very valuable, too.
However, output from a diagnosis tool must never be seen as a mandatory "must fix" issue. Often, those warnings or errors will be false positives, and if you "fix" the problem, you will break the program.
Now, about Code Completion and semaphores, I must admit that I've never understood the tampering that's being done there (especially not why it depends on the platform when a semaphore should signalled). Personally, I would have chosen a different design from the beginning, abstracting the whole thread stuff into a class that does that, and only that (as in FileManager, for example).
But whatever it is, the present implementation more or less works. So, unless someone is willing to rewrite that whole big ugly thing from scratch, I'd recommend to not touch it. Tampering with something one doesn't understand (and I assume none of us
really understands) most often makes things worse.