- removed threader from version tracker

- replaced mutexes with critical sections for windows

--HG--
extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%401093
This commit is contained in:
David Anderson 2007-07-09 23:42:30 +00:00
parent 3c31cfe8f5
commit 411f7693c3
3 changed files with 13 additions and 35 deletions

View File

@ -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()

View File

@ -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
{

View File

@ -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