From 51027a8c1c41e87b327408424cf4172296cd9fed Mon Sep 17 00:00:00 2001 From: Charlie Fenton Date: Tue, 4 Nov 2008 02:39:16 +0000 Subject: [PATCH] MGR: RPC thread restore Yield(); paus thread immediately on wxEVT_RPC_FINISHED event; reduce CPU usage while not connected to a client. svn path=/trunk/boinc/; revision=16402 --- clientgui/AsyncRPC.cpp | 33 ++++++++++++++++------- mac_build/English.lproj/InfoPlist.strings | 4 +-- 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/clientgui/AsyncRPC.cpp b/clientgui/AsyncRPC.cpp index 061c436e42..4cd7d5b5e4 100755 --- a/clientgui/AsyncRPC.cpp +++ b/clientgui/AsyncRPC.cpp @@ -123,12 +123,21 @@ void *RPCThread::Entry() { // Wait until CMainDocument issues next RPC request if (!m_pDoc->GetCurrentRPCRequest()->isActive) { - Sleep(100); +#ifdef __WXMSW__ // Until we can suspend the thread without Deadlock on Windows + Sleep(1); +#else + Yield(); +#endif continue; } - if (!m_pDoc->IsConnected()) { - Sleep(100); + if (! m_pDoc->IsConnected()) { +#ifdef _WIN32 + Sleep(1); +#else + timespec ts = {0, 1000}; /// 1 millisecond + nanosleep(&ts, NULL); /// 1 millisecond or less +#endif } retval = ProcessRPCRequest(); @@ -584,6 +593,17 @@ void CMainDocument::HandleCompletedRPC() { // called from RequestRPC, the CRPCFinishedEvent will still be // on the event queue, so we get called twice. Check for this here. if (current_rpc_request.which_rpc == 0) return; // already handled by a call from RequestRPC +#ifndef __WXMSW__ // Deadlocks on Windows + m_RPCThread->Pause(); + // Pause() does not take effect until the RPC thread calls TestDestroy() + // We must wait for that to happen to avoid a possible race condition. + do { + // TODO: is there a way for main UNIX thread to yield wih no minimum delay? + timespec ts = {0, 1}; /// 1 nanosecond + nanosleep(&ts, NULL); /// 1 nanosecond or less + } while (!m_RPCThread->IsPaused()); + +#endif // Find our completed request in the queue n = RPC_requests.size(); @@ -809,13 +829,6 @@ void CMainDocument::HandleCompletedRPC() { if (m_RPCThread->IsPaused()) { m_RPCThread->Resume(); } - } else { - m_RPCThread->Pause(); - while (!m_RPCThread->IsPaused()) { - // TODO: is there a way for main UNIX thread to yield wih no minimum delay? - timespec ts = {0, 1}; /// 1 nanosecond - nanosleep(&ts, NULL); /// 1 nanosecond or less - } #endif // ! __WXMSW__ // Deadlocks on Windows } } diff --git a/mac_build/English.lproj/InfoPlist.strings b/mac_build/English.lproj/InfoPlist.strings index 98496bea4d..7493cd264b 100755 --- a/mac_build/English.lproj/InfoPlist.strings +++ b/mac_build/English.lproj/InfoPlist.strings @@ -1,5 +1,5 @@ /* Localized versions of Info.plist keys */ CFBundleName = "BOINC"; -CFBundleShortVersionString = "BOINC version 6.3.4"; -CFBundleGetInfoString = "BOINC version 6.3.4, Copyright 2007 University of California."; +CFBundleShortVersionString = "BOINC version 6.3.21"; +CFBundleGetInfoString = "BOINC version 6.3.21, Copyright 2007 University of California.";