The current code with two QWaitConditions, a mutex and a bool lead
to a TSAN warning about lock order inversion: the first for loop locks
mutexes M0, M1, M2 etc. and then the second for loop calls QWaitCondition::wait(M0)
which unlocks+relocks M0, while M1 is locked.
It was also racy, in my opinion: with QWaitCondition there's the risk of
calling wakeOne before the other thread calls wait, and then the
notification is missed.
Ported to QSemaphore which doesn't have either problem.
Change-Id: I41574e944a2631cf42a81d3923abb658c862c25d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>