Index: ext/libicpf/src/dmutex.cpp =================================================================== diff -u -r2a38ed9af6573b03e881ecf726fab6a3746f8cfd -rd4269744a04d36c8a8146a84bc27118031fa42ac --- ext/libicpf/src/dmutex.cpp (.../dmutex.cpp) (revision 2a38ed9af6573b03e881ecf726fab6a3746f8cfd) +++ ext/libicpf/src/dmutex.cpp (.../dmutex.cpp) (revision d4269744a04d36c8a8146a84bc27118031fa42ac) @@ -7,38 +7,34 @@ /////////////////////////////////////////////////////////////// // debuggable mutex +/// Static dump context +dumpctx* d_mutex::m_pContext=NULL; + /** Constructs an unnamed mutex with a given dump context which will receive * notifications about locking and unlocking of this mutex. - * - * \param[in] pctx - dump context that will receive notifications about lock/unlock */ -d_mutex::d_mutex(dumpctx* pctx) - : mutex(pctx), +d_mutex::d_mutex() : + mutex(), m_ulLockCount(0) { const char_t* psz="Unnamed"; m_pszName=new char_t[strlen(psz)+1]; strcpy(m_pszName, psz); - m_pContext=pctx; - m_ulLockCount=0; } /** Constructs a named mutex with a given dump context which will receive * notifications about locking and unlocking of this mutex. * * \param[in] pszStr - name of this mutex (will be used for logging purposes) - * \param[in] pctx - dump context that will receive notifications about lock/unlock */ -d_mutex::d_mutex(const char_t* pszStr, dumpctx* pctx) : - mutex(pszStr, pctx), +d_mutex::d_mutex(const char_t* pszStr) : + mutex(pszStr), m_ulLockCount(0) { m_pszName=new char_t[strlen(pszStr)+1]; strcpy(m_pszName, pszStr); - - m_pContext=pctx; } /** Destructs the object @@ -59,6 +55,8 @@ { assert(m_pContext); + ((mutex*)this)->lock(); + m_ulLockCount++; // log the attempt and lock it @@ -67,8 +65,6 @@ m_pContext->open(sz); m_pContext->close(); - - ((mutex*)this)->lock(); } /** Unlocks this mutex. Takes some parameters that should identify the place in code which Index: ext/libicpf/src/dmutex.h =================================================================== diff -u -r12de61bfcf4d1ffef0339bee2e4c4a152209fd30 -rd4269744a04d36c8a8146a84bc27118031fa42ac --- ext/libicpf/src/dmutex.h (.../dmutex.h) (revision 12de61bfcf4d1ffef0339bee2e4c4a152209fd30) +++ ext/libicpf/src/dmutex.h (.../dmutex.h) (revision d4269744a04d36c8a8146a84bc27118031fa42ac) @@ -45,9 +45,9 @@ public: /** \name Construction/destruction */ /**@{*/ - d_mutex(dumpctx* pctx); ///< Constructs an unnamed mutex - d_mutex(const char_t* pszStr, dumpctx* pctx); ///< Constructs a named mutex - virtual ~d_mutex(); ///< Standard destructor + d_mutex(); ///< Constructs an unnamed mutex + d_mutex(const char_t* pszStr); ///< Constructs a named mutex + virtual ~d_mutex(); ///< Standard destructor /**@}*/ // standard locking @@ -57,10 +57,12 @@ void unlock(const char_t* pszFile, ulong_t ulLine, const char_t* pszFunction); ///< Unlocking with logging /**@}*/ +public: + static dumpctx* m_pContext; ///< Dump context that will receive informations about locking/unlocking + private: - char* m_pszName; ///< Name of the mutex - dumpctx* m_pContext; ///< Dump context that will receive informations about locking/unlocking - ulong_t m_ulLockCount; ///< Current lock count + char* m_pszName; ///< Name of the mutex + ulong_t m_ulLockCount; ///< Current lock count }; END_ICPF_NAMESPACE Index: ext/libicpf/src/mutex.cpp =================================================================== diff -u -r12de61bfcf4d1ffef0339bee2e4c4a152209fd30 -rd4269744a04d36c8a8146a84bc27118031fa42ac --- ext/libicpf/src/mutex.cpp (.../mutex.cpp) (revision 12de61bfcf4d1ffef0339bee2e4c4a152209fd30) +++ ext/libicpf/src/mutex.cpp (.../mutex.cpp) (revision d4269744a04d36c8a8146a84bc27118031fa42ac) @@ -17,18 +17,10 @@ construct(); } -/** Compatibility layer constructor (with d_mutex). Can take a fake dumpctx pointer, although - * does nothing with it. Effectively it is almost the same as standard constructor. - */ -mutex::mutex(void* /*pUnused*/) -{ - construct(); -} - /** Compatibility layer constructor (with d_mutex). Can take a fake dumpctx pointer and a fake mutex name, * although does nothing with it. Effectively it is almost the same as standard constructor. */ -mutex::mutex(const char_t* /*pszStr*/, void* /*pUnused*/) +mutex::mutex(const char_t* /*pszStr*/) { construct(); } Index: ext/libicpf/src/mutex.h =================================================================== diff -u -r96aff5934401b9dd5654e6b67806e68680f315f2 -rd4269744a04d36c8a8146a84bc27118031fa42ac --- ext/libicpf/src/mutex.h (.../mutex.h) (revision 96aff5934401b9dd5654e6b67806e68680f315f2) +++ ext/libicpf/src/mutex.h (.../mutex.h) (revision d4269744a04d36c8a8146a84bc27118031fa42ac) @@ -48,13 +48,12 @@ public: /** \name Construction/destruction */ /**@{*/ - mutex(); ///< Standard constructor - mutex(void* /*pUnused*/); ///< Helper constructor, used as a compatibility layer with d_mutex - mutex(const char_t* /*pszStr*/, void* /*pUnused*/); ///< Helper constructor, used as a compatibility layer with d_mutex + mutex(); ///< Standard constructor + mutex(const char_t* /*pszStr*/); ///< Helper constructor, used as a compatibility layer with d_mutex - virtual ~mutex(); ///< Standard destructor + virtual ~mutex(); ///< Standard destructor /**@}*/ - + /** \name Locking/unlocking */ /**@{*/ void lock(); ///< Locks this mutex