diff options
author | dwight <dwight@10gen.com> | 2012-02-14 10:41:03 -0500 |
---|---|---|
committer | dwight <dwight@10gen.com> | 2012-02-14 10:41:03 -0500 |
commit | 43812da4d30efbe9482fa054e47f1139a0703699 (patch) | |
tree | c519fb738c10d632a4349b8c322c598f803b7cf0 /src/mongo/util/concurrency/mutex.h | |
parent | 1086922c94158f160ebaf232dc1c337777bbf0a7 (diff) | |
download | mongo-43812da4d30efbe9482fa054e47f1139a0703699.tar.gz |
fix dassertLocked for windows false positives
Diffstat (limited to 'src/mongo/util/concurrency/mutex.h')
-rw-r--r-- | src/mongo/util/concurrency/mutex.h | 26 |
1 files changed, 7 insertions, 19 deletions
diff --git a/src/mongo/util/concurrency/mutex.h b/src/mongo/util/concurrency/mutex.h index 2689a4081ae..d3a7518e5bc 100644 --- a/src/mongo/util/concurrency/mutex.h +++ b/src/mongo/util/concurrency/mutex.h @@ -113,8 +113,7 @@ namespace mongo { boost::timed_mutex *_m; }; - typedef mutex::scoped_lock scoped_lock; - typedef boost::recursive_mutex::scoped_lock recursive_scoped_lock; + typedef mongo::mutex::scoped_lock scoped_lock; /** The concept with SimpleMutex is that it is a basic lock/unlock with no special functionality (such as try and try timeout). Thus it can be @@ -128,39 +127,28 @@ namespace mongo { SimpleMutex(const char *name) { InitializeCriticalSection(&_cs); } ~SimpleMutex() { DeleteCriticalSection(&_cs); } -#if defined(_DEBUG) - ThreadLocalValue<int> _nlocksByMe; void lock() { - assert( _nlocksByMe.get() == 0 ); // indicates you rae trying to lock recursively - _nlocksByMe.set(1); EnterCriticalSection(&_cs); +#if defined(_DEBUG) + assert( _cs.RecursionCount == 1 ); +#endif } void dassertLocked() const { - assert( _nlocksByMe.get() == 1 ); +#if defined(_DEBUG) + assert( _cs.OwningThread == (HANDLE) GetCurrentThreadId() ); +#endif } void unlock() { dassertLocked(); - _nlocksByMe.set(0); - LeaveCriticalSection(&_cs); - } -#else - void dassertLocked() const { } - void lock() { - EnterCriticalSection(&_cs); - } - void unlock() { LeaveCriticalSection(&_cs); } -#endif class scoped_lock : boost::noncopyable { SimpleMutex& _m; public: scoped_lock( SimpleMutex &m ) : _m(m) { _m.lock(); } ~scoped_lock() { _m.unlock(); } -# if defined(_DEBUG) const SimpleMutex& m() const { return _m; } -# endif }; }; #else |