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.

40 lines
593 B

  1. // lock.h : locking classes for BrowserCap
  2. #pragma once
  3. #ifndef _LOCK_H_
  4. #define _LOCK_H_
  5. // a lockable map template
  6. template< class T >
  7. class TSafeStringMap : public TStringMap<T>, public CComAutoCriticalSection
  8. {
  9. };
  10. template< class T >
  11. class TSafeVector : public TVector<T>, public CComAutoCriticalSection
  12. {
  13. };
  14. // a stack-based auto-lock template
  15. template< class T >
  16. class TLock
  17. {
  18. public:
  19. TLock( T& t )
  20. : m_t( t )
  21. {
  22. m_t.Lock();
  23. }
  24. ~TLock()
  25. {
  26. m_t.Unlock();
  27. }
  28. private:
  29. T& m_t;
  30. };
  31. typedef TLock<CComAutoCriticalSection> CLock;
  32. #endif