28 #define MTLOCK_IMP_EXP __declspec(dllexport)
30 #define MTLOCK_IMP_EXP __declspec(dllimport)
51 void SetSpinCount(DWORD dwSpinCount);
55 volatile DWORD m_dwSpinCount;
56 volatile long m_lLockCount;
57 volatile DWORD m_dwThreadId;
58 volatile long m_lRecurseCount;
59 } SHAREDINFO, *PSHAREDINFO;
61 BOOL m_fUniprocessorHost;
64 volatile PSHAREDINFO m_pSharedInfo;
66 BOOL CommonConstructor(PVOID pszName, BOOL fUnicode, DWORD dwSpinCount);
127 CRITICAL_SECTION criticalSection;
172 bool lockRead( DWORD Timeout = INFINITE );
173 bool lockWrite( DWORD Timeout = INFINITE );
174 void unlockRead( DWORD Timeout = INFINITE );
175 void unlockWrite( DWORD Timeout = INFINITE );
200 bool IsReader() {
return ReadCount > 0; };
201 bool IsWriter() {
return WriteCount > 0; };
204 typedef std::map<DWORD, KThreadInfo> KThreadMap;
205 KThreadMap m_Threads;
209 int m_TotalReaderThreads;
210 int m_TotalWriterThreads;
213 HANDLE m_WriterMutex;
219 ++m_TotalReaderThreads;
220 ResetEvent(m_CanWrite);
225 if (--m_TotalReaderThreads == 0)
226 SetEvent(m_CanWrite);
231 ++m_TotalWriterThreads;
232 ResetEvent(m_CanRead);
237 if (--m_TotalWriterThreads == 0)
245 bool lockRead( DWORD Timeout = INFINITE );
246 bool lockWrite( DWORD Timeout = INFINITE );
247 void unlockRead( DWORD Timeout = INFINITE );
248 void unlockWrite( DWORD Timeout = INFINITE );