开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜