diff options
author | George Hazan <george.hazan@gmail.com> | 2012-07-23 15:44:06 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2012-07-23 15:44:06 +0000 |
commit | 6923945a269905e5990d2f66dfa1bbb445e60f70 (patch) | |
tree | 30790d1cdd40398d50106bbc58377ad8cb2609b9 /src/mir_core/modules.cpp | |
parent | fbd49cdebcf274f8a1a1bb08317bd10992a77030 (diff) |
minor improvement for async calls
git-svn-id: http://svn.miranda-ng.org/main/trunk@1126 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src/mir_core/modules.cpp')
-rw-r--r-- | src/mir_core/modules.cpp | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/mir_core/modules.cpp b/src/mir_core/modules.cpp index ec9ff1160a..8372e966c3 100644 --- a/src/mir_core/modules.cpp +++ b/src/mir_core/modules.cpp @@ -86,10 +86,9 @@ static int QueueMainThread(PAPCFUNC pFunc, void* pParam, HANDLE hDoneEvent) {
int result = QueueUserAPC(pFunc, hMainThread, (ULONG_PTR)pParam);
PostMessage(hAPCWindow, WM_NULL, 0, 0); // let this get processed in its own time
- if (hDoneEvent) {
+ if (hDoneEvent)
WaitForSingleObject(hDoneEvent, INFINITE);
- CloseHandle(hDoneEvent);
- }
+
return result;
}
@@ -257,8 +256,12 @@ MIR_CORE_DLL(int) NotifyEventHooks(HANDLE hEvent, WPARAM wParam, LPARAM lParam) if ( GetCurrentThreadId() == mainThreadId)
return CallHookSubscribers((THook*)hEvent, wParam, lParam);
+ MThreadData* pData = (MThreadData*)TlsGetValue(mir_tls);
+ if (pData == NULL)
+ return -1;
+
mir_ptr<THookToMainThreadItem> item;
- item->hDoneEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
+ item->hDoneEvent = pData->m_hEvent;
item->hook = (THook*)hEvent;
item->wParam = wParam;
item->lParam = lParam;
@@ -527,11 +530,15 @@ MIR_CORE_DLL(INT_PTR) CallServiceSync(const char *name, WPARAM wParam, LPARAM lP if (GetCurrentThreadId() == mainThreadId)
return CallService(name, wParam, lParam);
+ MThreadData* pData = (MThreadData*)TlsGetValue(mir_tls);
+ if (pData == NULL)
+ return CALLSERVICE_NOTFOUND;
+
mir_ptr<TServiceToMainThreadItem> item;
item->wParam = wParam;
item->lParam = lParam;
item->name = name;
- item->hDoneEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
+ item->hDoneEvent = pData->m_hEvent;
QueueMainThread(CallServiceToMainAPCFunc, item, item->hDoneEvent);
return item->result;
}
|