开发者

Why need a null mutex?

开发者 https://www.devze.com 2023-01-15 04:31 出处:网络
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.

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

精彩评论

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