X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;ds=sidebyside;f=include%2Fthreadengines%2Fthreadengine_win32.h;h=77999e541bbceed68fc337d507de1f7e8191593f;hb=635cb9d65f6d7f6758ae8ed874da00c8d94b6e39;hp=bf8658853915b649774f51c54eea6ffe59585549;hpb=a77b9081d4e17bfe8b887073c09d531b2f4c4842;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/include/threadengines/threadengine_win32.h b/include/threadengines/threadengine_win32.h index bf8658853..77999e541 100644 --- a/include/threadengines/threadengine_win32.h +++ b/include/threadengines/threadengine_win32.h @@ -1,8 +1,12 @@ /* * InspIRCd -- Internet Relay Chat Daemon * + * Copyright (C) 2014 Attila Molnar + * Copyright (C) 2013 Sadie Powell + * Copyright (C) 2012 Robby + * Copyright (C) 2012 ChrisTX * Copyright (C) 2009 Daniel De Graaf - * Copyright (C) 2008 Craig Edwards + * Copyright (C) 2008-2010 Craig Edwards * * This file is part of InspIRCd. InspIRCd is free software: you can * redistribute it and/or modify it under the terms of the GNU General Public @@ -20,7 +24,6 @@ #pragma once -#include "config.h" #include "base.h" class Thread; @@ -71,7 +74,7 @@ class CoreExport ThreadEngine /** The Mutex class represents a mutex, which can be used to keep threads * properly synchronised. Use mutexes sparingly, as they are a good source * of thread deadlocks etc, and should be avoided except where absolutely - * neccessary. Note that the internal behaviour of the mutex varies from OS + * necessary. Note that the internal behaviour of the mutex varies from OS * to OS depending on the thread engine, for example in windows a Mutex * in InspIRCd uses critical sections, as they are faster and simpler to * manage. @@ -99,9 +102,8 @@ class CoreExport Mutex } }; -class ThreadQueueData +class ThreadQueueData : public Mutex { - CRITICAL_SECTION mutex; HANDLE event; public: ThreadQueueData() @@ -109,23 +111,11 @@ class ThreadQueueData event = CreateEvent(NULL, false, false, NULL); if (event == NULL) throw CoreException("CreateEvent() failed in ThreadQueueData::ThreadQueueData()!"); - InitializeCriticalSection(&mutex); } ~ThreadQueueData() { CloseHandle(event); - DeleteCriticalSection(&mutex); - } - - void Lock() - { - EnterCriticalSection(&mutex); - } - - void Unlock() - { - LeaveCriticalSection(&mutex); } void Wakeup() @@ -135,9 +125,9 @@ class ThreadQueueData void Wait() { - LeaveCriticalSection(&mutex); + Unlock(); WaitForSingleObject(event, INFINITE); - EnterCriticalSection(&mutex); + Lock(); } };