Leaked source code of windows server 2003
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.
|
|
/*==========================================================================
* Copyright (C) 1999, 2000 Microsoft Corporation. All Rights Reserved. * * File: dvcslock.h * Content: Class to handle auto-leave of critical sections * History: * Date By Reason * ==== == ====== * 07/05/00 rodtoll Created It * ***************************************************************************/ #ifndef __DVCSLOCK_H
#define __DVCSLOCK_H
// CDVCSLock
//
// A class to provide automatic unlocking of critical sections when the object
// passes out of scope.
//
class CDVCSLock { public: CDVCSLock( DNCRITICAL_SECTION *pcs ): m_pcs( pcs ), m_fLocked( FALSE ) { };
~CDVCSLock() { if( m_fLocked ) DNLeaveCriticalSection( m_pcs ); }
void Lock() { DNEnterCriticalSection( m_pcs ); m_fLocked = TRUE; }
void Unlock() { DNLeaveCriticalSection( m_pcs ); m_fLocked = FALSE; }
private:
DNCRITICAL_SECTION *m_pcs; BOOL m_fLocked; };
#endif
|