diff --git a/checkin_notes b/checkin_notes index 273919cc89..ffd367fbc1 100644 --- a/checkin_notes +++ b/checkin_notes @@ -5993,3 +5993,19 @@ Charlie 23 July 2008 BOINCBaseFrame.cpp,.h BOINCGUIApp.cpp,.h MainDocument.cpp,.h + +Charlie 23 July 2008 + - MGR: async GUI RPCs: Get RPCs all working in separate thread; + temporarily ignore timer events which would do RPCs while + a previous RPC request is in progress. + + clientgui/ + AdvancedFrame.cpp + AsyncRPC.cpp + BOINCBaseFrame.cpp + BOINCGUIApp.cpp,.h + BOINCTaskBar.cpp + MainDocument.cpp,.h + sg_BoincSimpleGUI.cpp + sg_DlgMessages.cpp + sg_ProjectsComponent.cpp diff --git a/clientgui/AdvancedFrame.cpp b/clientgui/AdvancedFrame.cpp index 7965def48f..d334941d24 100644 --- a/clientgui/AdvancedFrame.cpp +++ b/clientgui/AdvancedFrame.cpp @@ -1559,6 +1559,7 @@ void CAdvancedFrame::OnOptionsOptions(wxCommandEvent& WXUNUSED(event)) { wxASSERT(wxDynamicCast(pDoc, CMainDocument)); wxASSERT(wxDynamicCast(pSkinAdvanced, CSkinAdvanced)); +pDoc->TestAsyncRPC(); return; // TEMPORARY FOR TESTING ASYNC RPCs -- CAF // General Tab dlg.m_LanguageSelectionCtrl->Append(wxGetApp().GetSupportedLanguages()); @@ -1936,6 +1937,7 @@ void CAdvancedFrame::OnFrameRender(wxTimerEvent &event) { CMainDocument* pDoc = wxGetApp().GetDocument(); wxMenuBar* pMenuBar = GetMenuBar(); + if (wxGetApp().ProcessingRPC) return; // TEMPORARY UNTIL PERIODIC ASYNC RPCs IMPLEMENTED -- CAF if (!bAlreadyRunningLoop && m_pFrameRenderTimer->IsRunning()) { bAlreadyRunningLoop = true; @@ -2024,6 +2026,7 @@ void CAdvancedFrame::OnFrameRender(wxTimerEvent &event) { void CAdvancedFrame::OnListPanelRender(wxTimerEvent& WXUNUSED(event)) { + if (wxGetApp().ProcessingRPC) return; // TEMPORARY UNTIL PERIODIC ASYNC RPCs IMPLEMENTED -- CAF FireRefreshView(); } diff --git a/clientgui/AsyncRPC.cpp b/clientgui/AsyncRPC.cpp index 367f3c9012..aee290067f 100644 --- a/clientgui/AsyncRPC.cpp +++ b/clientgui/AsyncRPC.cpp @@ -115,7 +115,6 @@ void RPCThread::OnExit() { m_Doc->m_RPCThread = NULL; } -static int theRetVal; // TEMPORARY until I fix CRPCFinishedEvent::GetInt() and CRPCFinishedEvent::setInt() // We don't need critical sections because: // 1. CMainDocument never modifies mDoc->current_rpc_request while the @@ -139,14 +138,13 @@ void *RPCThread::Entry() { if (! m_Doc->IsConnected()) { Yield(); - continue; +// continue; } retval = ProcessRPCRequest(); CRPCFinishedEvent RPC_done_event( wxEVT_RPC_FINISHED ); RPC_done_event.SetInt(retval); -theRetVal = retval; // TEMPORARY until I fix CRPCFinishedEvent::GetInt() and CRPCFinishedEvent::setInt() wxPostEvent( wxTheApp, RPC_done_event ); } @@ -392,7 +390,7 @@ int RPCThread::ProcessRPCRequest() { // TODO: combine RPC requests for different buffers, then just copy the buffer. int CMainDocument::RequestRPC(ASYNC_RPC_REQUEST& request, bool hasPriority) { - static bool inUserRequest = false; +// static bool inUserRequest = false; std::vector::iterator iter; int retval = 0, retval2 = 0; @@ -435,26 +433,38 @@ int CMainDocument::RequestRPC(ASYNC_RPC_REQUEST& request, bool hasPriority) { // wait for completion but show a dialog allowing the user to cancel. if (request.event == NULL) { // TODO: proper handling if a second user request is received while first is pending - if (inUserRequest) { +// if (inUserRequest) { + if (m_bWaitingForRPC) { wxLogMessage(wxT("Second user RPC request while another was pending")); wxASSERT(false); +#if 0 + while (m_bWaitingForRPC) { + ::wxSafeYield(NULL, true); // Continue processing events + } + return retval; +#else return -1; +#endif } - inUserRequest = true; +// inUserRequest = true; + m_bWaitingForRPC = true; // Don't show dialog if RPC completes before RPC_WAIT_DLG_DELAY wxStopWatch Dlgdelay = wxStopWatch(); - m_RPCWaitDlg = new AsyncRPCDlg(); + wxGetApp().ProcessingRPC = true; // TEMPORARY UNTIL PERIODIC ASYNC RPCs IMPLEMENTED -- CAF +// CBOINCBaseFrame* pFrame = wxGetApp().GetFrame(); +// wxASSERT(wxDynamicCast(pFrame, CBOINCBaseFrame)); + + m_RPCWaitDlg = new AsyncRPCDlg(); do { - // OnRPCComplete() sets m_RPCWaitDlg to NULL if RPC completed - if (! m_RPCWaitDlg) { - inUserRequest = false; +// ::wxSafeYield(pFrame, true); // Continue processing events + wxTheApp->Yield(true); // Continue processing events + // OnRPCComplete() clears m_bWaitingForRPC if RPC completed + if (! m_bWaitingForRPC) { +// inUserRequest = false; + wxGetApp().ProcessingRPC = false; // TEMPORARY UNTIL PERIODIC ASYNC RPCs IMPLEMENTED -- CAF return retval; } -// ::wxSafeYield(NULL, true); // Continue processing events - wxGetApp().ProcessRPCFinishedEvents(); - - } while (Dlgdelay.Time() < RPC_WAIT_DLG_DELAY); // GetCurrentProcess(&psn); // SetFrontProcess(&psn); // Shows process if hidden @@ -499,22 +509,21 @@ int CMainDocument::RequestRPC(ASYNC_RPC_REQUEST& request, bool hasPriority) { retval2 = m_RPCThread->Run(); wxASSERT(!retval2); } + if (m_RPCWaitDlg) { + m_RPCWaitDlg->Destroy(); + } + m_RPCWaitDlg = NULL; + m_bWaitingForRPC = false; + wxGetApp().ProcessingRPC = false; // TEMPORARY UNTIL PERIODIC ASYNC RPCs IMPLEMENTED -- CAF } - if (m_RPCWaitDlg) { - m_RPCWaitDlg->Destroy(); - } - m_RPCWaitDlg = NULL; } - inUserRequest = false; - } - + } return retval; } void CMainDocument::OnRPCComplete(CRPCFinishedEvent& event) { int retval = event.GetInt(); -retval = theRetVal; // TEMPORARY until I fix CRPCFinishedEvent::GetInt() and CRPCFinishedEvent::setInt() int i, n; std::vector completed_RPC_requests; bool stillWaitingForPendingRequests = false; @@ -712,6 +721,7 @@ retval = theRetVal; // TEMPORARY until I fix CRPCFinishedEvent::GetInt() and CRP m_RPCWaitDlg = NULL; } } + m_bWaitingForRPC = false; } } diff --git a/clientgui/BOINCBaseFrame.cpp b/clientgui/BOINCBaseFrame.cpp index ad71e892e0..fa33acaccb 100644 --- a/clientgui/BOINCBaseFrame.cpp +++ b/clientgui/BOINCBaseFrame.cpp @@ -143,6 +143,8 @@ void CBOINCBaseFrame::OnDocumentPoll(wxTimerEvent& WXUNUSED(event)) { wxASSERT(pDoc); wxASSERT(wxDynamicCast(pDoc, CMainDocument)); + if (wxGetApp().ProcessingRPC) return; // TEMPORARY UNTIL PERIODIC ASYNC RPCs IMPLEMENTED -- CAF + if (!bAlreadyRunOnce && m_pDocumentPollTimer->IsRunning()) { // Complete any remaining initialization that has to happen after we are up // and running @@ -158,6 +160,8 @@ void CBOINCBaseFrame::OnAlertPoll(wxTimerEvent& WXUNUSED(event)) { static bool bAlreadyRunningLoop = false; CMainDocument* pDoc = wxGetApp().GetDocument(); + if (wxGetApp().ProcessingRPC) return; // TEMPORARY UNTIL PERIODIC ASYNC RPCs IMPLEMENTED -- CAF + if (!bAlreadyRunningLoop && m_pAlertPollTimer->IsRunning()) { bAlreadyRunningLoop = true; diff --git a/clientgui/BOINCGUIApp.cpp b/clientgui/BOINCGUIApp.cpp index cb52d63e7a..befa9a2e71 100644 --- a/clientgui/BOINCGUIApp.cpp +++ b/clientgui/BOINCGUIApp.cpp @@ -75,6 +75,8 @@ END_EVENT_TABLE () bool CBOINCGUIApp::OnInit() { // Setup variables with default values + ProcessingRPC = false; // TEMPORARY UNTIL PERIODIC ASYNC RPCs IMPLEMENTED -- CAF + m_strBOINCArguments = wxEmptyString; m_strBOINCMGRRootDirectory = wxEmptyString; m_strBOINCMGRDataDirectory = wxEmptyString; @@ -639,13 +641,6 @@ void CBOINCGUIApp::OnRPCFinished( CRPCFinishedEvent& event ) { } -bool CBOINCGUIApp::ProcessRPCFinishedEvents() { - CRPCFinishedEvent RPC_done_event( wxEVT_RPC_FINISHED ); - - return SearchEventTable(*(wxEventTable*)GetEventTable(), (wxEvent&)RPC_done_event); -} - - int CBOINCGUIApp::UpdateSystemIdleDetection() { #ifdef __WXMSW__ return BOINCGetIdleTickCount(); diff --git a/clientgui/BOINCGUIApp.h b/clientgui/BOINCGUIApp.h index cbcf618103..700271e3c7 100644 --- a/clientgui/BOINCGUIApp.h +++ b/clientgui/BOINCGUIApp.h @@ -126,7 +126,7 @@ public: bool SetActiveGUI(int iGUISelection, bool bShowWindow = true); virtual void OnRPCFinished( CRPCFinishedEvent& event ); - bool ProcessRPCFinishedEvents(); + bool ProcessingRPC; // TEMPORARY UNTIL PERIODIC ASYNC RPCs IMPLEMENTED -- CAF int ConfirmExit(); diff --git a/clientgui/BOINCTaskBar.cpp b/clientgui/BOINCTaskBar.cpp index d113d194a1..fdedacee51 100644 --- a/clientgui/BOINCTaskBar.cpp +++ b/clientgui/BOINCTaskBar.cpp @@ -133,12 +133,14 @@ void CTaskBarIcon::OnClose(wxCloseEvent& event) { void CTaskBarIcon::OnRefresh(wxTimerEvent& WXUNUSED(event)) { wxLogTrace(wxT("Function Start/End"), wxT("CTaskBarIcon::OnRefresh - Function Begin")); - CMainDocument* pDoc = wxGetApp().GetDocument(); + CMainDocument* pDoc = wxGetApp().GetDocument(); CC_STATUS status; wxASSERT(pDoc); wxASSERT(wxDynamicCast(pDoc, CMainDocument)); + if (wxGetApp().ProcessingRPC) return; // TEMPORARY UNTIL PERIODIC ASYNC RPCs IMPLEMENTED -- CAF + // What is the current status of the client? pDoc->GetCoreClientStatus(status); @@ -487,7 +489,10 @@ bool CTaskBarIcon::SetIcon(const wxIcon& icon) { currentIcon = &icon; - result = wxGetApp().GetMacSystemMenu()->SetIcon(icon); + CMacSystemMenu* sysMenu = wxGetApp().GetMacSystemMenu(); + if (sysMenu == NULL) return 0; + + result = sysMenu->SetIcon(icon); RestoreApplicationDockTileImage(); // Remove any previous badge diff --git a/clientgui/MainDocument.cpp b/clientgui/MainDocument.cpp index e95c8a6579..3385358cb2 100644 --- a/clientgui/MainDocument.cpp +++ b/clientgui/MainDocument.cpp @@ -379,6 +379,7 @@ int CMainDocument::OnInit() { wxASSERT(m_pClientManager); m_RPCWaitDlg = NULL; + m_bWaitingForRPC = false; current_rpc_request.clear(); m_RPCThread = new RPCThread(this); diff --git a/clientgui/MainDocument.h b/clientgui/MainDocument.h index d6ef541d8b..08c4103315 100644 --- a/clientgui/MainDocument.h +++ b/clientgui/MainDocument.h @@ -179,6 +179,7 @@ private: ASYNC_RPC_REQUEST current_rpc_request; AsyncRPCDlg* m_RPCWaitDlg; std::vector RPC_requests; + bool m_bWaitingForRPC; // // Project Tab diff --git a/clientgui/sg_BoincSimpleGUI.cpp b/clientgui/sg_BoincSimpleGUI.cpp index 8733bc70c4..b291161c3f 100644 --- a/clientgui/sg_BoincSimpleGUI.cpp +++ b/clientgui/sg_BoincSimpleGUI.cpp @@ -543,6 +543,8 @@ void CSimplePanel::OnProjectsAttachToProject() { void CSimplePanel::OnFrameRender(wxTimerEvent& WXUNUSED(event)) { CMainDocument* pDoc = wxGetApp().GetDocument(); + if (wxGetApp().ProcessingRPC) return; // TEMPORARY UNTIL PERIODIC ASYNC RPCs IMPLEMENTED -- CAF + if (IsShown()) { if (!projectViewInitialized) { diff --git a/clientgui/sg_DlgMessages.cpp b/clientgui/sg_DlgMessages.cpp index cf4a6177f4..1a928f1451 100644 --- a/clientgui/sg_DlgMessages.cpp +++ b/clientgui/sg_DlgMessages.cpp @@ -339,6 +339,8 @@ void CPanelMessages::OnRefresh(wxTimerEvent& event) { bool isConnected; static bool was_connected = false; + if (wxGetApp().ProcessingRPC) return; // TEMPORARY UNTIL PERIODIC ASYNC RPCs IMPLEMENTED -- CAF + if (!m_bProcessingRefreshEvent) { m_bProcessingRefreshEvent = true; diff --git a/clientgui/sg_ProjectsComponent.cpp b/clientgui/sg_ProjectsComponent.cpp index a90546b570..4709a51995 100644 --- a/clientgui/sg_ProjectsComponent.cpp +++ b/clientgui/sg_ProjectsComponent.cpp @@ -731,6 +731,9 @@ void CProjectsComponent::OnEraseBackground(wxEraseEvent& event){ void CProjectsComponent::OnMessageCheck(wxTimerEvent& WXUNUSED(event)) { CMainDocument* pDoc = wxGetApp().GetDocument(); MESSAGE* message; + + if (wxGetApp().ProcessingRPC) return; // TEMPORARY UNTIL PERIODIC ASYNC RPCs IMPLEMENTED -- CAF + // Only look at the messages recieved since the last time we looked if ( pDoc->GetMessageCount() > (int) lastMessageId ) { // Loop through and check for any messages recieved that are error messages