Merge "Use semaphore instead of condition variable" into tm-dev