summaryrefslogtreecommitdiff
path: root/include/threadengines/threadengine_win32.h
diff options
context:
space:
mode:
authorAttila Molnar <attilamolnar@hush.com>2014-06-24 13:09:26 +0200
committerAttila Molnar <attilamolnar@hush.com>2014-06-24 13:09:26 +0200
commitd2760311db1446951b6a3894f7dc1f6a8f3ee931 (patch)
tree94a1e2b202598f589d303aa5201a66d8ae5bb771 /include/threadengines/threadengine_win32.h
parentddb1710aa3dc12566c80658d8dc577c07c5dc98b (diff)
Inherit ThreadQueueData from Mutex to avoid duplicating code
Diffstat (limited to 'include/threadengines/threadengine_win32.h')
-rw-r--r--include/threadengines/threadengine_win32.h19
1 files changed, 3 insertions, 16 deletions
diff --git a/include/threadengines/threadengine_win32.h b/include/threadengines/threadengine_win32.h
index bf8658853..aac7b8b97 100644
--- a/include/threadengines/threadengine_win32.h
+++ b/include/threadengines/threadengine_win32.h
@@ -99,9 +99,8 @@ class CoreExport Mutex
}
};
-class ThreadQueueData
+class ThreadQueueData : public Mutex
{
- CRITICAL_SECTION mutex;
HANDLE event;
public:
ThreadQueueData()
@@ -109,23 +108,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 +122,9 @@ class ThreadQueueData
void Wait()
{
- LeaveCriticalSection(&mutex);
+ Unlock();
WaitForSingleObject(event, INFINITE);
- EnterCriticalSection(&mutex);
+ Lock();
}
};