diff options
author | George Hazan <george.hazan@gmail.com> | 2013-03-11 15:11:36 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2013-03-11 15:11:36 +0000 |
commit | 6aeafa47b02b966067d3ff83453c9ae8f9b0fc70 (patch) | |
tree | 30a31a165c2712d6af297cf4819fc5787f5344d7 /plugins/Clist_modern/src/modern_gettextasync.cpp | |
parent | 1ba746b6a4c979841a3b3452347da0aa78964f95 (diff) |
only a few real mir_forkthreadex survived
git-svn-id: http://svn.miranda-ng.org/main/trunk@3977 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Clist_modern/src/modern_gettextasync.cpp')
-rw-r--r-- | plugins/Clist_modern/src/modern_gettextasync.cpp | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/plugins/Clist_modern/src/modern_gettextasync.cpp b/plugins/Clist_modern/src/modern_gettextasync.cpp index 1244e8b49c..4c4bbe5b89 100644 --- a/plugins/Clist_modern/src/modern_gettextasync.cpp +++ b/plugins/Clist_modern/src/modern_gettextasync.cpp @@ -76,18 +76,18 @@ static BOOL gtaGetItem(GTACHAINITEM * mpChain) return FALSE;
}
-static unsigned __stdcall gtaThreadProc(void * lpParam)
+static void gtaThreadProc(void *lpParam)
{
+ thread_catcher lck(g_hGetTextAsyncThread);
HWND hwnd = pcli->hwndContactList;
- struct SHORTDATA data = {0};
+ SHORTDATA data = {0};
while (!MirandaExiting()) {
Sync(CLUI_SyncGetShortData,(WPARAM)pcli->hwndContactTree,(LPARAM)&data);
while (true) {
- if (MirandaExiting()) {
- g_dwGetTextAsyncThreadID = 0;
- return 0;
- }
+ if ( MirandaExiting())
+ return;
+
SleepEx(0, TRUE); //1000 contacts per second
GTACHAINITEM mpChain = {0};
@@ -102,10 +102,8 @@ static unsigned __stdcall gtaThreadProc(void * lpParam) Sync(CLUI_SyncGetShortData,(WPARAM)mpChain.dat->hWnd,(LPARAM)&dat2);
dat = &dat2;
}
- if ( MirandaExiting()) {
- g_dwGetTextAsyncThreadID = 0;
- return 0;
- }
+ if ( MirandaExiting())
+ return;
ClcCacheEntry cacheEntry;
memset(&cacheEntry, 0, sizeof(cacheEntry));
@@ -124,13 +122,11 @@ static unsigned __stdcall gtaThreadProc(void * lpParam) WaitForSingleObjectEx(hgtaWakeupEvent, INFINITE, TRUE);
ResetEvent(hgtaWakeupEvent);
}
- g_dwGetTextAsyncThreadID = 0;
- return 1;
}
BOOL gtaWakeThread()
{
- if (hgtaWakeupEvent && g_dwGetTextAsyncThreadID) {
+ if (hgtaWakeupEvent && g_hGetTextAsyncThread) {
SetEvent(hgtaWakeupEvent);
return TRUE;
}
@@ -178,14 +174,14 @@ void InitCacheAsync() {
InitializeCriticalSection(>aCS);
hgtaWakeupEvent = CreateEvent(NULL,FALSE,FALSE,NULL);
- mir_forkthreadex(gtaThreadProc, 0, &g_dwGetTextAsyncThreadID);
+ g_hGetTextAsyncThread = mir_forkthread(gtaThreadProc, 0);
HookEvent(ME_SYSTEM_PRESHUTDOWN, gtaOnModulesUnload);
}
void UninitCacheAsync()
{
SetEvent(hgtaWakeupEvent);
- while(g_dwGetTextAsyncThreadID)
+ while(g_hGetTextAsyncThread)
SleepEx(50, TRUE);
CloseHandle(hgtaWakeupEvent);
|