From 63c123fdc565d574c41e92f39b7cf183b35a0fcf Mon Sep 17 00:00:00 2001 From: Rom Walton Date: Tue, 4 Nov 2008 00:00:59 +0000 Subject: [PATCH] - MGR: Use Sleep instead of Yield for the async thread loop. On Posix systems all Yield translates to is sched_yield but only if HAVE_SCHED_YIELD is defined in the wxWidget config file. If it isn't defined it becomes a null op. The async thread doesn't really need millisecond response times. Have it check every 100 milliseconds for an RPC to process. clientgui/ AsyncRPC.cpp svn path=/trunk/boinc/; revision=16398 --- checkin_notes | 11 +++++++++++ clientgui/AsyncRPC.cpp | 20 +++++++------------- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/checkin_notes b/checkin_notes index 980a8e5bbb..95dd34d12a 100644 --- a/checkin_notes +++ b/checkin_notes @@ -9036,3 +9036,14 @@ David 3 Nov 2008 cpu_sched.cpp sched/ file_deleter.cpp + +Rom 3 Nov 2008 + - MGR: Use Sleep instead of Yield for the async thread loop. On Posix + systems all Yield translates to is sched_yield but only if + HAVE_SCHED_YIELD is defined in the wxWidget config file. If it isn't + defined it becomes a null op. The async thread doesn't really need + millisecond response times. Have it check every 100 milliseconds + for an RPC to process. + + clientgui/ + AsyncRPC.cpp diff --git a/clientgui/AsyncRPC.cpp b/clientgui/AsyncRPC.cpp index 736d9fcda1..061c436e42 100755 --- a/clientgui/AsyncRPC.cpp +++ b/clientgui/AsyncRPC.cpp @@ -118,23 +118,17 @@ void *RPCThread::Entry() { int retval; CRPCFinishedEvent RPC_done_event( wxEVT_RPC_FINISHED ); - while(true) { - // check if we were asked to exit - if ( TestDestroy() ) - break; + // check if we were asked to exit + while(!TestDestroy()) { - if (! m_pDoc->GetCurrentRPCRequest()->isActive) { - // Wait until CMainDocument issues next RPC request -#ifdef __WXMSW__ // Until we can suspend the thread without Deadlock on Windows - Sleep(1); -#else - Yield(); -#endif + // Wait until CMainDocument issues next RPC request + if (!m_pDoc->GetCurrentRPCRequest()->isActive) { + Sleep(100); continue; } - if (! m_pDoc->IsConnected()) { - Yield(); + if (!m_pDoc->IsConnected()) { + Sleep(100); } retval = ProcessRPCRequest();