diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/threadengine.cpp | 3 | ||||
-rw-r--r-- | src/threadengines/threadengine_pthread.cpp | 26 | ||||
-rw-r--r-- | src/threadengines/threadengine_win32.cpp | 26 |
3 files changed, 55 insertions, 0 deletions
diff --git a/src/threadengine.cpp b/src/threadengine.cpp index a6e17afa0..49538f891 100644 --- a/src/threadengine.cpp +++ b/src/threadengine.cpp @@ -28,3 +28,6 @@ ThreadEngine::~ThreadEngine() { } +Mutex::Mutex(InspIRCd* Instance) : ServerInstance(Instance) +{ +} diff --git a/src/threadengines/threadengine_pthread.cpp b/src/threadengines/threadengine_pthread.cpp index 2f09cc305..626cd4d55 100644 --- a/src/threadengines/threadengine_pthread.cpp +++ b/src/threadengines/threadengine_pthread.cpp @@ -105,3 +105,29 @@ void PThreadEngine::FreeThread(Thread* thread) } } +MutexEngine::MutexEngine(InspIRCd* Instance) : ServerInstance(Instance) +{ +} + +Mutex* MutexEngine::CreateMutex() +{ + return new PosixMutex(this->ServerInstance); +} + +PosixMutex::PosixMutex(InspIRCd* Instance) : Mutex(Instance) +{ + InitializeCriticalSection(&putex); +} + +PosixMutex::~PosixMutex() +{ + DeleteCriticalSection(&putex); +} + +void PosixMutex::Enable(bool enable) +{ + if (enable) + pthread_mutex_lock(&putex); + else + pthread_mutex_unlock(&putex); +} diff --git a/src/threadengines/threadengine_win32.cpp b/src/threadengines/threadengine_win32.cpp index 566611367..e2b58b42e 100644 --- a/src/threadengines/threadengine_win32.cpp +++ b/src/threadengines/threadengine_win32.cpp @@ -86,3 +86,29 @@ void Win32ThreadEngine::FreeThread(Thread* thread) } +MutexEngine::MutexEngine(InspIRCd* Instance) : ServerInstance(Instance) +{ +} + +Mutex* MutexEngine::CreateMutex() +{ + return new Win32Mutex(this->ServerInstance); +} + +Win32Mutex::Win32Mutex(InspIRCd* Instance) : Mutex(Instance) +{ + InitializeCriticalSection(&wutex); +} + +Win32Mutex::~Win32Mutex() +{ + DeleteCriticalSection(&wutex); +} + +void Win32Mutex::Enable(bool enable) +{ + if (enable) + EnterCriticalSection(&wutex); + else + LeaveCriticalSection(&wutex); +}
\ No newline at end of file |