Robert Shearman : ole: Use the thread pool for executing RPC calls for better performance

Alexandre Julliard julliard at wine.codeweavers.com
Mon Mar 20 06:17:40 CST 2006


Module: wine
Branch: refs/heads/master
Commit: 650ac14219ea9ee286e9d537e75b0deb77f1b434
URL:    http://source.winehq.org/git/?p=wine.git;a=commit;h=650ac14219ea9ee286e9d537e75b0deb77f1b434

Author: Robert Shearman <rob at codeweavers.com>
Date:   Sat Mar 18 16:09:53 2006 +0000

ole: Use the thread pool for executing RPC calls for better performance
(after the thread pool has been improved).

---

 dlls/ole32/rpc.c |   15 +++++++--------
 1 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/dlls/ole32/rpc.c b/dlls/ole32/rpc.c
index 3c5f3ea..6715f72 100644
--- a/dlls/ole32/rpc.c
+++ b/dlls/ole32/rpc.c
@@ -220,12 +220,14 @@ static HRESULT WINAPI ServerRpcChannelBu
 static DWORD WINAPI rpc_sendreceive_thread(LPVOID param)
 {
     struct dispatch_params *data = (struct dispatch_params *) param;
-    
+
     /* FIXME: trap and rethrow RPC exceptions in app thread */
     data->status = I_RpcSendReceive((RPC_MESSAGE *)data->msg);
 
     TRACE("completed with status 0x%lx\n", data->status);
-    
+
+    SetEvent(data->handle);
+
     return 0;
 }
 
@@ -249,7 +251,6 @@ static HRESULT WINAPI ClientRpcChannelBu
     RPC_STATUS status;
     DWORD index;
     struct dispatch_params *params;
-    DWORD tid;
     APARTMENT *apt = NULL;
     IPID ipid;
 
@@ -279,10 +280,9 @@ static HRESULT WINAPI ClientRpcChannelBu
 
     RpcBindingInqObject(msg->Handle, &ipid);
     hr = ipid_get_dispatch_params(&ipid, &apt, &params->stub, &params->chan);
+    params->handle = CreateEventW(NULL, FALSE, FALSE, NULL);
     if ((hr == S_OK) && !apt->multi_threaded)
     {
-        params->handle = CreateEventW(NULL, FALSE, FALSE, NULL);
-
         TRACE("Calling apartment thread 0x%08lx...\n", apt->tid);
 
         if (!PostMessageW(apartment_getwindow(apt), DM_EXECUTERPC, 0, (LPARAM)params))
@@ -309,10 +309,9 @@ static HRESULT WINAPI ClientRpcChannelBu
          * and re-enter this STA from an incoming server thread will
          * deadlock. InstallShield is an example of that.
          */
-        params->handle = CreateThread(NULL, 0, rpc_sendreceive_thread, params, 0, &tid);
-        if (!params->handle)
+        if (!QueueUserWorkItem(rpc_sendreceive_thread, params, WT_EXECUTEDEFAULT))
         {
-            ERR("Could not create RpcSendReceive thread, error %lx\n", GetLastError());
+            ERR("QueueUserWorkItem failed with error %lx\n", GetLastError());
             hr = E_UNEXPECTED;
         }
         else




More information about the wine-cvs mailing list