Why need a null mutex?
Why would one need a mutex object where the Acquire and release methods just return 0?
I am studying the ACE framework and it has a Null_Mutex class, and I was wondering how it would come to use.
class Null_Mutex
{
public:
Null_Mutex (void) {}
˜Null_Mutex (void) {}
int remove (void) { return 0; }
int acquire (void) const { return 0;开发者_Go百科 }
int try_acquire (void) const { return 0; }
int release (void) const { return 0; }
};
It's null object pattern: you can pass it to code requiring mutex when you don't need actual mutex logic.
精彩评论