diff options
-rw-r--r-- | include/threadengine.h | 18 | ||||
-rw-r--r-- | include/threadengines/threadengine_win32.h | 4 | ||||
-rw-r--r-- | src/threadengine.cpp | 12 |
3 files changed, 20 insertions, 14 deletions
diff --git a/include/threadengine.h b/include/threadengine.h index e1400eb95..c11f2d817 100644 --- a/include/threadengine.h +++ b/include/threadengine.h @@ -20,6 +20,12 @@ #include "inspircd_config.h" #include "base.h" +#ifdef WINDOWS +#include "threadengines/threadengine_win32.h" +#endif + +class ThreadData; + /** Derive from this class to implement your own threaded sections of * code. Be sure to keep your code thread-safe and not prone to deadlocks * and race conditions if you MUST use threading! @@ -49,17 +55,7 @@ class CoreExport Thread : public Extensible { } - /** If this thread has a Creator set, call it to - * free the thread - */ - virtual ~Thread() - { - if (state) - { - state->FreeThread(this); - delete state; - } - } + virtual ~Thread(); /** Override this method to put your actual * threaded code here. diff --git a/include/threadengines/threadengine_win32.h b/include/threadengines/threadengine_win32.h index 0fc9b27bc..6bd1c2c00 100644 --- a/include/threadengines/threadengine_win32.h +++ b/include/threadengines/threadengine_win32.h @@ -77,7 +77,7 @@ class CoreExport Mutex private: CRITICAL_SECTION wutex; public: - Win32Mutex() + Mutex() { InitializeCriticalSection(&wutex); } @@ -89,7 +89,7 @@ class CoreExport Mutex { LeaveCriticalSection(&wutex); } - ~Win32Mutex() + ~Mutex() { DeleteCriticalSection(&wutex); } diff --git a/src/threadengine.cpp b/src/threadengine.cpp index e7a316282..faa020234 100644 --- a/src/threadengine.cpp +++ b/src/threadengine.cpp @@ -20,4 +20,14 @@ #include "inspircd.h" #include "threadengine.h" - +/** If this thread has a Creator set, call it to + * free the thread + */ +virtual ~Thread::Thread() +{ + if (state) + { + state->FreeThread(this); + delete state; + } +} |