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.

41 lines
749 B

  1. /*++
  2. Copyright (C) 1996-2001 Microsoft Corporation
  3. Module Name:
  4. TLS.H
  5. Abstract:
  6. Thread Local Storage
  7. History:
  8. --*/
  9. #ifndef __WBEM_TLS__H_
  10. #define __WBEM_TLS__H_
  11. #include <statsync.h>
  12. class CTLS
  13. {
  14. protected:
  15. DWORD m_dwIndex;
  16. public:
  17. inline CTLS()
  18. {
  19. m_dwIndex = TlsAlloc();
  20. if (TLS_OUT_OF_INDEXES == m_dwIndex)
  21. CStaticCritSec::SetFailure();
  22. }
  23. inline ~CTLS() {TlsFree(m_dwIndex);}
  24. inline void* Get()
  25. {return ((TLS_OUT_OF_INDEXES == m_dwIndex)?NULL:TlsGetValue(m_dwIndex));}
  26. inline void Set(void* p)
  27. {if(TLS_OUT_OF_INDEXES != m_dwIndex) TlsSetValue(m_dwIndex, p);}
  28. inline DWORD GetIndex(){ return m_dwIndex; };
  29. };
  30. #endif