mirror of https://github.com/BOINC/boinc.git
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.
svn path=/workspaces/charlief/; revision=15667
This commit is contained in:
parent
f73295a123
commit
f48643e837
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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<ASYNC_RPC_REQUEST>::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<ASYNC_RPC_REQUEST> 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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -179,6 +179,7 @@ private:
|
|||
ASYNC_RPC_REQUEST current_rpc_request;
|
||||
AsyncRPCDlg* m_RPCWaitDlg;
|
||||
std::vector<ASYNC_RPC_REQUEST> RPC_requests;
|
||||
bool m_bWaitingForRPC;
|
||||
|
||||
//
|
||||
// Project Tab
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue