mirror of https://github.com/tongzx/nt5src
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
1.2 KiB
55 lines
1.2 KiB
#ifndef _GENCRITICALSECTION_H
|
|
#define _GENCRITICALSECTION_H
|
|
|
|
/////////////////////////////////////
|
|
// This class doesn't do much now,
|
|
// but this may help when we try to
|
|
// optimize the Lock and Unlocks'
|
|
/////////////////////////////////////
|
|
|
|
typedef interface IGenCriticalSection
|
|
{
|
|
// Data members
|
|
public:
|
|
|
|
private:
|
|
protected:
|
|
CRITICAL_SECTION m_cs;
|
|
|
|
// Methods
|
|
public:
|
|
IGenCriticalSection() { ::InitializeCriticalSection ( &m_cs ); }
|
|
~IGenCriticalSection() { ::DeleteCriticalSection ( &m_cs ); }
|
|
|
|
virtual void ReadLock ( void ) = 0;
|
|
virtual void ReadUnlock ( void ) = 0;
|
|
|
|
virtual void WriteLock ( void ) = 0;
|
|
virtual void WriteUnlock ( void ) = 0;
|
|
|
|
private:
|
|
|
|
protected:
|
|
|
|
}IGenCriticalSection, *PGenCriticalSection, **PPGenCriticalSection;
|
|
|
|
class CGenCriticalSection : public IGenCriticalSection
|
|
{
|
|
// Data members
|
|
public:
|
|
private:
|
|
protected:
|
|
|
|
// Methods
|
|
public:
|
|
|
|
private:
|
|
protected:
|
|
virtual void ReadLock ( void ) { ::EnterCriticalSection (&m_cs); };
|
|
virtual void ReadUnlock ( void ) { ::LeaveCriticalSection (&m_cs); };
|
|
|
|
virtual void WriteLock ( void ) { ::EnterCriticalSection (&m_cs); };
|
|
virtual void WriteUnlock ( void ) { ::LeaveCriticalSection (&m_cs); };
|
|
};
|
|
|
|
#endif // _GENCRITICALSECTION_H
|