#ifndef WindowsCriticalSection_h #define WindowsCriticalSection_h #include <windows.h> namespace CoreFW { class __declspec( dllexport ) FWCriticalSection { private: mutable CRITICAL_SECTION m_CriticalSection ; void operator=( FWCriticalSection &CriticalSectionObject ) {} FWCriticalSection( const FWCriticalSection &CriticalSectionObject ) {} public: FWCriticalSection() { InitializeCriticalSection( &m_CriticalSection ) ; } virtual ~FWCriticalSection() { DeleteCriticalSection( &m_CriticalSection ) ; } bool Lock() const { EnterCriticalSection( &m_CriticalSection ) ; return true ; } #if(_WIN32_WINNT >= 0x0400) bool Lock_Try() const { return ( TryEnterCriticalSection( &m_CriticalSection ) == TRUE ) ; } #endif bool Unlock() const { LeaveCriticalSection( &m_CriticalSection ) ; return true ; } } ; } // End namespace #endif // WindowsCriticalSection_h
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.
This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)