I some开发者_运维技巧times need a "null" implementation of named_mutex(i.e. always succeeds and does nothing).
Is there is such implementation ? If not, what's the recommended way to implement?
Why not just have a class with empty definitions?
class named_mutex
{
public:
named_mutex(create_only_t, const char *) {}
named_mutex(open_or_create_t, const char *) {}
named_mutex(open_only_t, const char *) {}
~named_mutex() {}
void unlock() {}
void lock() {}
bool try_lock() {}
bool timed_lock(const boost::posix_time::ptime &) {}
static bool remove(const char *) {}
};
Use an instance of this as your named_mutex
and it's like it never existed.
精彩评论