Can a shared lock on a std::shared_timed_mutex be upgraded to an exclusive lock?
问题 The new std::shared_timed_mutex allows for two types of locks: shared and exclusive. If one holds a shared lock, is there any way to atomically exchange it ("upgrade it") to an exclusive lock? In other words, given the following code, how can I avoid the non-atomic drop and re-lock? std::shared_timed_mutex m; //Guards a std::vector. m.lock_shared(); //Read from vector. (Shared lock is sufficient.) // ... //Now we want to write to the vector. We need an exclusive lock. m.unlock_shared(); // <-