Semaphore changed with a C++ 11 mutex for protection.