I find the ability to drop in a null_mutex (currently boost::interprocess::null_mutex) very useful when I don't want the synchronization overhead in some cases and a real mutex in others.
I am trying to use the new c++11 mutex classes, but I see no equivalent for null_mutex - which leaves me puzzled..
Yes I know it's trivial to implement (or I can continue to use boost, but where possible I'm trying to stick the standard and seems like a small omission?)
You can make this fairly trivially, by creating a 'null' implementation of the Lockable concept:
struct null_mutex
{
void lock() {}
void unlock() noexcept {}
bool try_lock() { return true; }
};
This would work with std::lock_guard:
null_mutex mux;
std::lock_guard<null_mutex> guard(mux);
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