diff options
| author | Jørgen P. Tjernø <[email protected]> | 2013-12-02 19:31:46 -0800 |
|---|---|---|
| committer | Jørgen P. Tjernø <[email protected]> | 2013-12-02 19:46:31 -0800 |
| commit | f56bb35301836e56582a575a75864392a0177875 (patch) | |
| tree | de61ddd39de3e7df52759711950b4c288592f0dc /sp/src/utils/vmpi/threadhelpers.h | |
| parent | Mark some more files as text. (diff) | |
| download | source-sdk-2013-f56bb35301836e56582a575a75864392a0177875.tar.xz source-sdk-2013-f56bb35301836e56582a575a75864392a0177875.zip | |
Fix line endings. WHAMMY.
Diffstat (limited to 'sp/src/utils/vmpi/threadhelpers.h')
| -rw-r--r-- | sp/src/utils/vmpi/threadhelpers.h | 220 |
1 files changed, 110 insertions, 110 deletions
diff --git a/sp/src/utils/vmpi/threadhelpers.h b/sp/src/utils/vmpi/threadhelpers.h index 1e955a5e..bfba74f3 100644 --- a/sp/src/utils/vmpi/threadhelpers.h +++ b/sp/src/utils/vmpi/threadhelpers.h @@ -1,110 +1,110 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose:
-//
-// $NoKeywords: $
-//=============================================================================//
-
-#ifndef THREADHELPERS_H
-#define THREADHELPERS_H
-#ifdef _WIN32
-#pragma once
-#endif
-
-
-#include "tier1/utllinkedlist.h"
-
-
-#define SIZEOF_CS 24 // sizeof( CRITICAL_SECTION )
-
-
-class CCriticalSection
-{
-public:
- CCriticalSection();
- ~CCriticalSection();
-
-
-protected:
-
- friend class CCriticalSectionLock;
-
- void Lock();
- void Unlock();
-
-
-public:
- char m_CS[SIZEOF_CS];
-
- // Used to protect against deadlock in debug mode.
-//#if defined( _DEBUG )
- CUtlLinkedList<unsigned long,int> m_Locks;
- char m_DeadlockProtect[SIZEOF_CS];
-//#endif
-};
-
-
-// Use this to lock a critical section.
-class CCriticalSectionLock
-{
-public:
- CCriticalSectionLock( CCriticalSection *pCS );
- ~CCriticalSectionLock();
- void Lock();
- void Unlock();
-
-private:
- CCriticalSection *m_pCS;
- bool m_bLocked;
-};
-
-
-template< class T >
-class CCriticalSectionData : private CCriticalSection
-{
-public:
- // You only have access to the data between Lock() and Unlock().
- T* Lock()
- {
- CCriticalSection::Lock();
- return &m_Data;
- }
-
- void Unlock()
- {
- CCriticalSection::Unlock();
- }
-
-private:
- T m_Data;
-};
-
-
-
-// ------------------------------------------------------------------------------------------------ //
-// CEvent.
-// ------------------------------------------------------------------------------------------------ //
-class CEvent
-{
-public:
- CEvent();
- ~CEvent();
-
- bool Init( bool bManualReset, bool bInitialState );
- void Term();
-
- void* GetEventHandle() const;
-
- // Signal the event.
- bool SetEvent();
-
- // Unset the event's signalled status.
- bool ResetEvent();
-
-
-private:
- void *m_hEvent;
-};
-
-
-#endif // THREADHELPERS_H
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// + +#ifndef THREADHELPERS_H +#define THREADHELPERS_H +#ifdef _WIN32 +#pragma once +#endif + + +#include "tier1/utllinkedlist.h" + + +#define SIZEOF_CS 24 // sizeof( CRITICAL_SECTION ) + + +class CCriticalSection +{ +public: + CCriticalSection(); + ~CCriticalSection(); + + +protected: + + friend class CCriticalSectionLock; + + void Lock(); + void Unlock(); + + +public: + char m_CS[SIZEOF_CS]; + + // Used to protect against deadlock in debug mode. +//#if defined( _DEBUG ) + CUtlLinkedList<unsigned long,int> m_Locks; + char m_DeadlockProtect[SIZEOF_CS]; +//#endif +}; + + +// Use this to lock a critical section. +class CCriticalSectionLock +{ +public: + CCriticalSectionLock( CCriticalSection *pCS ); + ~CCriticalSectionLock(); + void Lock(); + void Unlock(); + +private: + CCriticalSection *m_pCS; + bool m_bLocked; +}; + + +template< class T > +class CCriticalSectionData : private CCriticalSection +{ +public: + // You only have access to the data between Lock() and Unlock(). + T* Lock() + { + CCriticalSection::Lock(); + return &m_Data; + } + + void Unlock() + { + CCriticalSection::Unlock(); + } + +private: + T m_Data; +}; + + + +// ------------------------------------------------------------------------------------------------ // +// CEvent. +// ------------------------------------------------------------------------------------------------ // +class CEvent +{ +public: + CEvent(); + ~CEvent(); + + bool Init( bool bManualReset, bool bInitialState ); + void Term(); + + void* GetEventHandle() const; + + // Signal the event. + bool SetEvent(); + + // Unset the event's signalled status. + bool ResetEvent(); + + +private: + void *m_hEvent; +}; + + +#endif // THREADHELPERS_H |