Replace Windows specific thread handling
Use the platform independent primitives instead.
diff --git a/win/rfb_win32/RegConfig.cxx b/win/rfb_win32/RegConfig.cxx
index 30cb310..5c89e78 100644
--- a/win/rfb_win32/RegConfig.cxx
+++ b/win/rfb_win32/RegConfig.cxx
@@ -85,30 +85,29 @@
}
-RegConfigThread::RegConfigThread() : Thread("RegConfigThread"), config(&eventMgr) {
+RegConfigThread::RegConfigThread() : config(&eventMgr), thread_id(-1) {
}
RegConfigThread::~RegConfigThread() {
- join();
+ PostThreadMessage(thread_id, WM_QUIT, 0, 0);
+ wait();
}
bool RegConfigThread::start(const HKEY rootKey, const TCHAR* keyname) {
if (config.setKey(rootKey, keyname)) {
Thread::start();
+ while (thread_id == (DWORD)-1)
+ Sleep(0);
return true;
}
return false;
}
-void RegConfigThread::run() {
+void RegConfigThread::worker() {
DWORD result = 0;
MSG msg;
+ thread_id = GetCurrentThreadId();
while ((result = eventMgr.getMessage(&msg, 0, 0, 0)) > 0) {}
if (result < 0)
throw rdr::SystemException("RegConfigThread failed", GetLastError());
}
-
-Thread* RegConfigThread::join() {
- PostThreadMessage(getThreadId(), WM_QUIT, 0, 0);
- return Thread::join();
-}