I find that the std::mutex
implementation in Visual Studio 2013 is too slow. It uses a heavy weight mutex to assure that synchronization can be achieved even between processes which is all fine and dandy; Unless you're not talking to other processes and could really use that extra speed that CRITICAL_SECTION
with it's spin-lock offers on Win32.
I tried to implement a fast_recursive_mutex
that adheres to the C++11 mutex concept and that fulfills all obligations according to spec. In all senses, it's a drop-in replacement for std::mutex
as long as you're not synchronizing between processes.
It works great with std::lock_guard
and std::unique_lock
. However I encounter problems when trying to use it with std::condition_variable
because std::condition_variable::wait(std::unique_lock<std::mutex>&)
doesn't admit my fast_recursive_mutex
due to the hard coded use of std::mutex
.
So my questions are:
wait()
not admit another mutex type than std::mutex
?You can use std::condition_variable_any
for any lockable type.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With