summaryrefslogtreecommitdiff
path: root/src/threadengines
diff options
context:
space:
mode:
authordanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2009-03-23 18:48:42 +0000
committerdanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2009-03-23 18:48:42 +0000
commitf9e6de5284aaacd55aa389445cd595bdcaa8339e (patch)
treea0fd4a21d17c5aa9d6a21c6b1e7e8022e25e6758 /src/threadengines
parent7b6eae36661bc798f69b22393b85a4f06d533cf6 (diff)
ThreadEngine: remove MutexFactory, mutexes should be constructed using their constructor
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11250 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/threadengines')
-rw-r--r--src/threadengines/threadengine_pthread.cpp39
-rw-r--r--src/threadengines/threadengine_win32.cpp43
2 files changed, 14 insertions, 68 deletions
diff --git a/src/threadengines/threadengine_pthread.cpp b/src/threadengines/threadengine_pthread.cpp
index 9fc9cc4b4..f5de69a6a 100644
--- a/src/threadengines/threadengine_pthread.cpp
+++ b/src/threadengines/threadengine_pthread.cpp
@@ -16,7 +16,7 @@
#include <pthread.h>
#include <signal.h>
-PThreadEngine::PThreadEngine(InspIRCd* Instance) : ThreadEngine(Instance)
+ThreadEngine::ThreadEngine(InspIRCd* Instance)
{
}
@@ -34,52 +34,25 @@ static void* entry_point(void* parameter)
}
-void PThreadEngine::Start(Thread* thread)
+void ThreadEngine::Start(Thread* thread)
{
- PThreadData* data = new PThreadData;
+ ThreadData* data = new ThreadData;
thread->state = data;
if (pthread_create(&data->pthread_id, NULL, entry_point, thread) != 0)
{
thread->state = NULL;
delete data;
- throw CoreException("Unable to create new PThreadEngine: " + std::string(strerror(errno)));
+ throw CoreException("Unable to create new thread: " + std::string(strerror(errno)));
}
}
-PThreadEngine::~PThreadEngine()
+ThreadEngine::~ThreadEngine()
{
}
-void PThreadData::FreeThread(Thread* thread)
+void ThreadData::FreeThread(Thread* thread)
{
thread->SetExitFlag(true);
pthread_join(pthread_id, NULL);
}
-
-MutexFactory::MutexFactory(InspIRCd* Instance) : ServerInstance(Instance)
-{
-}
-
-Mutex* MutexFactory::CreateMutex()
-{
- return new PosixMutex();
-}
-
-PosixMutex::PosixMutex() : Mutex()
-{
- pthread_mutex_init(&putex, NULL);
-}
-
-PosixMutex::~PosixMutex()
-{
- pthread_mutex_destroy(&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 b32dd2441..6ebd6a10a 100644
--- a/src/threadengines/threadengine_win32.cpp
+++ b/src/threadengines/threadengine_win32.cpp
@@ -14,67 +14,40 @@
#include "inspircd.h"
#include "threadengines/threadengine_win32.h"
-Win32ThreadEngine::Win32ThreadEngine(InspIRCd* Instance) : ThreadEngine(Instance)
+ThreadEngine::ThreadEngine(InspIRCd* Instance)
{
}
-void Win32ThreadEngine::Create(Thread* thread)
+void ThreadEngine::Create(Thread* thread)
{
- Win32ThreadData* data = new Win32ThreadData;
+ ThreadData* data = new ThreadData;
thread->state = data;
DWORD ThreadId = 0;
- data->handle = CreateThread(NULL,0,Win32ThreadEngine::Entry,thread,0,&ThreadId);
+ data->handle = CreateThread(NULL,0,ThreadEngine::Entry,thread,0,&ThreadId);
if (data->handle == NULL)
{
thread->state = NULL;
delete data;
- throw CoreException(std::string("Unable to create new Win32ThreadEngine: ") + dlerror());
+ throw CoreException(std::string("Unable to create new thread: ") + dlerror());
}
}
-Win32ThreadEngine::~Win32ThreadEngine()
+ThreadEngine::~ThreadEngine()
{
}
-DWORD WINAPI Win32ThreadEngine::Entry(void* parameter)
+DWORD WINAPI ThreadEngine::Entry(void* parameter)
{
Thread* pt = reinterpret_cast<Thread*>(parameter);
pt->Run();
return 0;
}
-void Win32ThreadData::FreeThread(Thread* thread)
+void ThreadData::FreeThread(Thread* thread)
{
thread->SetExitFlag();
WaitForSingleObject(handle,INFINITE);
}
-
-MutexFactory::MutexFactory(InspIRCd* Instance) : ServerInstance(Instance)
-{
-}
-
-Mutex* MutexFactory::CreateMutex()
-{
- return new Win32Mutex();
-}
-
-Win32Mutex::Win32Mutex() : Mutex()
-{
- InitializeCriticalSection(&wutex);
-}
-
-Win32Mutex::~Win32Mutex()
-{
- DeleteCriticalSection(&wutex);
-}
-
-void Win32Mutex::Enable(bool enable)
-{
- if (enable)
- EnterCriticalSection(&wutex);
- else
- LeaveCriticalSection(&wutex);
-}