25 Oct
2005
25 Oct
'05
1:14 p.m.
I'm trying to implement a class having a lock and an unlock-method. If several different threads call scoped_lock::lock, what is the effect? class AntiRAII{ public: AntiRAII() : mLock(mMutex, false) {} void Lock() {mLock.lock(); } void Unlock() {mLock.unlock();} private: boost::mutex mMutex; boost::mutex::scoped_lock mLock; }; I cannot find any documentation on the behaviour. The usual usage of scoped_lock is one per thread, which is why I'm sceptical to this approach. How can this be implemented? Is it better to expose the mutex? Regards, Johan Torp