Use two argument condition_variable::wait() instead of a loop.