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.

65 lines
2.0 KiB

  1. /*++
  2. Copyright (c) Microsoft Corporation
  3. Module Name:
  4. fusiondequelinkage.h
  5. Abstract:
  6. Author:
  7. Revision History:
  8. --*/
  9. #if !defined(_FUSION_INC_FUSIONDEQUELINKAGE_H_INCLUDED_)
  10. #define _FUSION_INC_FUSIONDEQUELINKAGE_H_INCLUDED_
  11. #pragma once
  12. #include "fusiontrace.h"
  13. class CDequeBase;
  14. class CDequeLinkage : protected LIST_ENTRY
  15. {
  16. friend CDequeBase;
  17. public:
  18. inline CDequeLinkage() : m_pDeque(NULL), m_ulLockCount(0) { this->Flink = NULL; this->Blink = NULL; }
  19. inline ~CDequeLinkage() { ASSERT_NTC(m_ulLockCount == 0); m_pDeque = NULL; }
  20. inline bool IsNotLocked() const { return (m_ulLockCount == 0); }
  21. #if DBG
  22. inline VOID Lock() { m_ulLockCount++; }
  23. inline VOID Unlock() { m_ulLockCount--; }
  24. #else
  25. inline VOID Lock() { }
  26. inline VOID Unlock() { }
  27. #endif
  28. inline VOID Remove() { this->Flink->Blink = this->Flink; this->Blink->Flink = this->Flink; }
  29. protected:
  30. inline VOID InitializeHead(CDequeBase *pDequeBase) { ASSERT_NTC(pDequeBase != NULL); this->Flink = this; this->Blink = this; this->m_pDeque = pDequeBase; }
  31. inline CDequeLinkage *GetFlink() const { return static_cast<CDequeLinkage *>(this->Flink); }
  32. inline CDequeLinkage *GetBlink() const { return static_cast<CDequeLinkage *>(this->Blink); }
  33. inline CDequeBase *GetDequeBase() const { return m_pDeque; }
  34. inline VOID SetDeque(CDequeBase *pDeque) { m_pDeque = pDeque; }
  35. inline VOID SetFlink(CDequeLinkage *pFlink) { this->Flink = pFlink; }
  36. inline VOID SetBlink(CDequeLinkage *pBlink) { this->Blink = pBlink; }
  37. CDequeBase *m_pDeque;
  38. // m_ulLockCount is incremented when an iterator is positioned on an entry, to stop
  39. // it from being deleted. Note that no interlocked synchronization is attempted;
  40. // this is merely to stop blatent programming errors. If you want multithreaded
  41. // access to the deque, you need to provide your own synchronization.
  42. ULONG m_ulLockCount;
  43. };
  44. #endif