BaseMutex. Waits until no other thread has locked the mutex.
The current thread must not have already locked the mutex. Reentrant locking is undefined behavior (inherited from the C++ implementation).
mutex.atomicallyOnce condvar pred k runs
pred returns true.
pred have access to the mutex's state.