diff --git a/core/thread/WinThreads.cpp b/core/thread/WinThreads.cpp index c67ffd1e..2180ed30 100644 --- a/core/thread/WinThreads.cpp +++ b/core/thread/WinThreads.cpp @@ -12,6 +12,7 @@ * Version: $Id$ */ +#define _WIN32_WINNT 0x0400 #include "WinThreads.h" #include "ThreadWorker.h" @@ -37,12 +38,7 @@ void WinThreader::ThreadSleep(unsigned int ms) IMutex *WinThreader::MakeMutex() { - HANDLE mutex = CreateMutexA(NULL, FALSE, NULL); - - if (mutex == NULL) - return NULL; - - WinMutex *pMutex = new WinMutex(mutex); + WinMutex *pMutex = new WinMutex(); return pMutex; } @@ -141,40 +137,29 @@ IEventSignal *WinThreader::MakeEventSignal() **** Mutexes **** *****************/ +WinThreader::WinMutex::WinMutex() +{ + InitializeCriticalSection(&m_crit); +} + WinThreader::WinMutex::~WinMutex() { - if (m_mutex) - { - CloseHandle(m_mutex); - m_mutex = NULL; - } + DeleteCriticalSection(&m_crit); } bool WinThreader::WinMutex::TryLock() { - if (!m_mutex) - return false; - - if (WaitForSingleObject(m_mutex, 0) != WAIT_FAILED) - return true; - - return false; + return (TryEnterCriticalSection(&m_crit) != FALSE); } void WinThreader::WinMutex::Lock() { - if (!m_mutex) - return; - - WaitForSingleObject(m_mutex, INFINITE); + EnterCriticalSection(&m_crit); } void WinThreader::WinMutex::Unlock() { - if (!m_mutex) - return; - - ReleaseMutex(m_mutex); + LeaveCriticalSection(&m_crit); } void WinThreader::WinMutex::DestroyThis() diff --git a/core/thread/WinThreads.h b/core/thread/WinThreads.h index de693028..956ccf82 100644 --- a/core/thread/WinThreads.h +++ b/core/thread/WinThreads.h @@ -52,9 +52,7 @@ public: class WinMutex : public IMutex { public: - WinMutex(HANDLE mutex) : m_mutex(mutex) - { - }; + WinMutex(); virtual ~WinMutex(); public: virtual bool TryLock(); @@ -62,7 +60,7 @@ public: virtual void Unlock(); virtual void DestroyThis(); protected: - HANDLE m_mutex; + CRITICAL_SECTION m_crit; }; class WinEvent : public IEventSignal { diff --git a/modules.versions b/modules.versions index 99969384..b7fd0acf 100644 --- a/modules.versions +++ b/modules.versions @@ -23,11 +23,6 @@ folder = extensions/geoip in = svn_version.tpl out = svn_version.h -[threader] -folder = extensions/threader -in = svn_version.tpl -out = svn_version.h - [compiler] folder = sourcepawn/compiler in = svn_version.tpl