00001
00027 #ifndef INC_MI32_CONTAINERITEMSYNC_H
00028 #define INC_MI32_CONTAINERITEMSYNC_H
00029
00030 #ifndef INC_MI32_CRITSEC_H
00031 #include <mi32/critsec.h>
00032 #endif
00033
00034 #ifndef INC_MI32_INTERLOCKEDINT32_H
00035 #include <mi32/interlockedint32.h>
00036 #endif
00037
00038 #ifdef MISYSTEMDLL
00039 #define CLASSLIBEXPORT MI_DLLCLASSEXPORT
00040 #else
00041 #define CLASSLIBEXPORT MI_DLLCLASSIMPORT
00042 #endif
00043
00044 namespace MITHREAD {
00045
00078 class CLASSLIBEXPORT CONTAINERITEMSYNC {
00079 private:
00080 #ifndef GENERATING_DOXYGEN_OUTPUT
00081 class PRIV;
00082 #endif // GENERATING_DOXYGEN_OUTPUT
00083
00084 public:
00088 class OBJECT {
00089 public:
00091 OBJECT (
00092 ) : m_Counter(0) { }
00093
00096 ~OBJECT (
00097 ) { Release(); }
00098
00101 void Release (
00102 ) {
00103 if (m_Counter != 0) {
00104 (*m_Counter)--;
00105 m_CacheLock.Release();
00106 m_Counter = 0;
00107 }
00108 return;
00109 }
00110
00111 private:
00112 #ifndef GENERATING_DOXYGEN_OUTPUT
00115 CRITICALSECTION::LOCK m_CacheLock;
00116 INTERLOCKEDINT32* m_Counter;
00117
00118 OBJECT (const OBJECT& rhs);
00119 OBJECT& operator=(const OBJECT& rhs);
00120
00121 friend class CONTAINERITEMSYNC::PRIV;
00122 #endif // GENERATING_DOXYGEN_OUTPUT
00123 };
00124
00126 CONTAINERITEMSYNC ();
00127
00129 ~CONTAINERITEMSYNC ();
00130
00135 void AcquireSyncObject (
00136 PTRUINT ItemID,
00137 OBJECT& SyncObject
00138 );
00139
00140 private:
00141 #ifndef GENERATING_DOXYGEN_OUTPUT
00142 PRIV* m_pPriv;
00143
00144 CONTAINERITEMSYNC (const CONTAINERITEMSYNC& rhs);
00145 CONTAINERITEMSYNC& operator=(const CONTAINERITEMSYNC& rhs);
00146 #endif // GENERATING_DOXYGEN_OUTPUT
00147 };
00148
00149 }
00150
00151 #undef CLASSLIBEXPORT
00152 #endif
00153