- 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:
parent
3c31cfe8f5
commit
411f7693c3
@ -12,6 +12,7 @@
|
|||||||
* Version: $Id$
|
* Version: $Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#define _WIN32_WINNT 0x0400
|
||||||
#include "WinThreads.h"
|
#include "WinThreads.h"
|
||||||
#include "ThreadWorker.h"
|
#include "ThreadWorker.h"
|
||||||
|
|
||||||
@ -37,12 +38,7 @@ void WinThreader::ThreadSleep(unsigned int ms)
|
|||||||
|
|
||||||
IMutex *WinThreader::MakeMutex()
|
IMutex *WinThreader::MakeMutex()
|
||||||
{
|
{
|
||||||
HANDLE mutex = CreateMutexA(NULL, FALSE, NULL);
|
WinMutex *pMutex = new WinMutex();
|
||||||
|
|
||||||
if (mutex == NULL)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
WinMutex *pMutex = new WinMutex(mutex);
|
|
||||||
|
|
||||||
return pMutex;
|
return pMutex;
|
||||||
}
|
}
|
||||||
@ -141,40 +137,29 @@ IEventSignal *WinThreader::MakeEventSignal()
|
|||||||
**** Mutexes ****
|
**** Mutexes ****
|
||||||
*****************/
|
*****************/
|
||||||
|
|
||||||
|
WinThreader::WinMutex::WinMutex()
|
||||||
|
{
|
||||||
|
InitializeCriticalSection(&m_crit);
|
||||||
|
}
|
||||||
|
|
||||||
WinThreader::WinMutex::~WinMutex()
|
WinThreader::WinMutex::~WinMutex()
|
||||||
{
|
{
|
||||||
if (m_mutex)
|
DeleteCriticalSection(&m_crit);
|
||||||
{
|
|
||||||
CloseHandle(m_mutex);
|
|
||||||
m_mutex = NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WinThreader::WinMutex::TryLock()
|
bool WinThreader::WinMutex::TryLock()
|
||||||
{
|
{
|
||||||
if (!m_mutex)
|
return (TryEnterCriticalSection(&m_crit) != FALSE);
|
||||||
return false;
|
|
||||||
|
|
||||||
if (WaitForSingleObject(m_mutex, 0) != WAIT_FAILED)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WinThreader::WinMutex::Lock()
|
void WinThreader::WinMutex::Lock()
|
||||||
{
|
{
|
||||||
if (!m_mutex)
|
EnterCriticalSection(&m_crit);
|
||||||
return;
|
|
||||||
|
|
||||||
WaitForSingleObject(m_mutex, INFINITE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WinThreader::WinMutex::Unlock()
|
void WinThreader::WinMutex::Unlock()
|
||||||
{
|
{
|
||||||
if (!m_mutex)
|
LeaveCriticalSection(&m_crit);
|
||||||
return;
|
|
||||||
|
|
||||||
ReleaseMutex(m_mutex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WinThreader::WinMutex::DestroyThis()
|
void WinThreader::WinMutex::DestroyThis()
|
||||||
|
@ -52,9 +52,7 @@ public:
|
|||||||
class WinMutex : public IMutex
|
class WinMutex : public IMutex
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
WinMutex(HANDLE mutex) : m_mutex(mutex)
|
WinMutex();
|
||||||
{
|
|
||||||
};
|
|
||||||
virtual ~WinMutex();
|
virtual ~WinMutex();
|
||||||
public:
|
public:
|
||||||
virtual bool TryLock();
|
virtual bool TryLock();
|
||||||
@ -62,7 +60,7 @@ public:
|
|||||||
virtual void Unlock();
|
virtual void Unlock();
|
||||||
virtual void DestroyThis();
|
virtual void DestroyThis();
|
||||||
protected:
|
protected:
|
||||||
HANDLE m_mutex;
|
CRITICAL_SECTION m_crit;
|
||||||
};
|
};
|
||||||
class WinEvent : public IEventSignal
|
class WinEvent : public IEventSignal
|
||||||
{
|
{
|
||||||
|
@ -23,11 +23,6 @@ folder = extensions/geoip
|
|||||||
in = svn_version.tpl
|
in = svn_version.tpl
|
||||||
out = svn_version.h
|
out = svn_version.h
|
||||||
|
|
||||||
[threader]
|
|
||||||
folder = extensions/threader
|
|
||||||
in = svn_version.tpl
|
|
||||||
out = svn_version.h
|
|
||||||
|
|
||||||
[compiler]
|
[compiler]
|
||||||
folder = sourcepawn/compiler
|
folder = sourcepawn/compiler
|
||||||
in = svn_version.tpl
|
in = svn_version.tpl
|
||||||
|
Loading…
Reference in New Issue
Block a user