diff options
author | Matthew Newhook <matthew@zeroc.com> | 2008-03-12 18:50:04 +0800 |
---|---|---|
committer | Matthew Newhook <matthew@zeroc.com> | 2008-03-12 18:50:04 +0800 |
commit | ba5bbb636402043f7dff5cdaa3444b66dd7bffbd (patch) | |
tree | 79ac9e34f32a41945d82826eb4196e859d26a3f9 /cpp/include/IceUtil/StaticMutex.h | |
parent | Fixed bug with fixVersion.py, and updated the IceStorm service version in tes... (diff) | |
download | ice-ba5bbb636402043f7dff5cdaa3444b66dd7bffbd.tar.bz2 ice-ba5bbb636402043f7dff5cdaa3444b66dd7bffbd.tar.xz ice-ba5bbb636402043f7dff5cdaa3444b66dd7bffbd.zip |
Squashed commit of the following:
I also got rid of some old 0x0400 compatibility stuff in RecMutex and StaticMutex.
commit 8e7277ac6d19922c9be8c4b12a12b909da36eb60
Author: U-MARCH3\matthew <matthew@march3.(none)>
Date: Wed Mar 12 18:19:15 2008 +0800
added missing file.
commit 3ac0a9fdf2c5d976b08d9bbf24b0144e2533c8db
Author: U-MARCH3\matthew <matthew@march3.(none)>
Date: Wed Mar 12 18:12:56 2008 +0800
bug 2752
Diffstat (limited to 'cpp/include/IceUtil/StaticMutex.h')
-rw-r--r-- | cpp/include/IceUtil/StaticMutex.h | 110 |
1 files changed, 5 insertions, 105 deletions
diff --git a/cpp/include/IceUtil/StaticMutex.h b/cpp/include/IceUtil/StaticMutex.h index 17b8d11d1a8..59fdb7f0581 100644 --- a/cpp/include/IceUtil/StaticMutex.h +++ b/cpp/include/IceUtil/StaticMutex.h @@ -39,7 +39,7 @@ class Cond; // // -class StaticMutex +class ICE_UTIL_API StaticMutex { public: @@ -59,18 +59,16 @@ public: // // Returns true if the lock was acquired, and false otherwise. // + // This method is not inlined under Win32 due to issues with VC6, + // MFC and WINVER >= 0x0400. See bug 2752 for details. + // bool tryLock() const; void unlock() const; #ifdef _WIN32 -# if defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x0400 mutable CRITICAL_SECTION* _mutex; -# else - mutable HANDLE _mutex; - mutable int _recursionCount; -# endif #else mutable pthread_mutex_t _mutex; #endif @@ -104,7 +102,7 @@ private: #ifdef _WIN32 inline bool initialized() const; - ICE_UTIL_API void initialize() const; + void initialize() const; #endif #ifndef _MSC_VER @@ -142,8 +140,6 @@ StaticMutex::initialized() const return InterlockedCompareExchangePointer(reinterpret_cast<void**>(&tmp), 0, 0) != 0; } -# if defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x0400 - inline void StaticMutex::lock() const { @@ -155,25 +151,6 @@ StaticMutex::lock() const assert(_mutex->RecursionCount == 1); } -inline bool -StaticMutex::tryLock() const -{ - if(!initialized()) - { - initialize(); - } - if(!TryEnterCriticalSection(_mutex)) - { - return false; - } - if(_mutex->RecursionCount > 1) - { - LeaveCriticalSection(_mutex); - throw ThreadLockedException(__FILE__, __LINE__); - } - return true; -} - inline void StaticMutex::unlock() const { @@ -200,83 +177,6 @@ StaticMutex::lock(LockState&) const EnterCriticalSection(_mutex); } -# else - -inline void -StaticMutex::lock() const -{ - if(!initialized()) - { - initialize(); - } - - DWORD rc = WaitForSingleObject(_mutex, INFINITE); - if(rc != WAIT_OBJECT_0) - { - if(rc == WAIT_FAILED) - { - throw ThreadSyscallException(__FILE__, __LINE__, GetLastError()); - } - else - { - throw ThreadSyscallException(__FILE__, __LINE__, 0); - } - } - _recursionCount++; - assert(_recursionCount == 1); -} - -inline bool -StaticMutex::tryLock() const -{ - if(!initialized()) - { - initialize(); - } - - DWORD rc = WaitForSingleObject(_mutex, 0); - if(rc != WAIT_OBJECT_0) - { - return false; - } - else if(_recursionCount == 1) - { - _recursionCount++; - unlock(); - throw ThreadLockedException(__FILE__, __LINE__); - } - else - { - _recursionCount++; - return true; - } -} - -inline void -StaticMutex::unlock() const -{ - _recursionCount--; - BOOL rc = ReleaseMutex(_mutex); - if(rc == 0) - { - throw ThreadSyscallException(__FILE__, __LINE__, GetLastError()); - } -} - -inline void -StaticMutex::unlock(LockState& state) const -{ - unlock(); -} - -inline void -StaticMutex::lock(LockState&) const -{ - lock(); -} - -# endif - #else inline void |