From f9e6de5284aaacd55aa389445cd595bdcaa8339e Mon Sep 17 00:00:00 2001 From: danieldg Date: Mon, 23 Mar 2009 18:48:42 +0000 Subject: 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 --- src/threadengines/threadengine_pthread.cpp | 39 +++++------------------------- 1 file changed, 6 insertions(+), 33 deletions(-) (limited to 'src/threadengines/threadengine_pthread.cpp') 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 #include -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); -} -- cgit v1.2.3