From c7435da167c4cec94d9f2da0410b5f544bb4c54d Mon Sep 17 00:00:00 2001 From: "Kevin M. Rosenberg" Date: Sun, 25 Feb 2001 08:00:57 +0000 Subject: [PATCH] r580: no message --- msvc/ctsim/ctsim.plg | 12 ++++---- src/backgroundsupr.cpp | 39 ++++++++--------------- src/backgroundsupr.h | 4 +-- src/threadrecon.cpp | 70 +++++++++++++++++++++++------------------- 4 files changed, 58 insertions(+), 67 deletions(-) diff --git a/msvc/ctsim/ctsim.plg b/msvc/ctsim/ctsim.plg index 02c55ab..249267f 100644 --- a/msvc/ctsim/ctsim.plg +++ b/msvc/ctsim/ctsim.plg @@ -6,13 +6,13 @@ --------------------Configuration: ctsim - Win32 Debug--------------------

Command Lines

-Creating temporary file "C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP247.tmp" with contents +Creating temporary file "C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP25B.tmp" with contents [ /nologo /G6 /MTd /W3 /Gm /Gi /GR /GX /Zi /Od /Gy /I "\wx2.2.5\include" /I "..\..\..\fftw-2.1.3\fftw" /I "\wx2.2.5\src\png" /I "\wx2.2.5\src\zlib" /I "..\..\include" /I "..\..\getopt" /I "..\..\..\fftw-2.1.3\rfftw" /D VERSION=\"3.0.0beta1\" /D "_DEBUG" /D "__WXMSW__" /D "HAVE_SGP" /D "HAVE_PNG" /D "HAVE_WXWINDOWS" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "HAVE_STRING_H" /D "HAVE_FFTW" /D "HAVE_RFFTW" /D "HAVE_GETOPT_H" /D "MSVC" /D "__WIN95__" /D "__WIN32__" /D WINVER=0x0400 /D "STRICT" /D CTSIMVERSION=\"3.0.4\" /FR"Debug/" /Fp"Debug/ctsim.pch" /YX /Fo"Debug/" /Fd"Debug/" /FD /GZ /c -"C:\ctsim\src\threadrecon.cpp" +"C:\ctsim\src\backgroundsupr.cpp" ] -Creating command line "cl.exe @C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP247.tmp" -Creating temporary file "C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP248.tmp" with contents +Creating command line "cl.exe @C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP25B.tmp" +Creating temporary file "C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP25C.tmp" with contents [ winmm.lib rpcrt4.lib ws2_32.lib ../libctsim/Debug/libctsim.lib libcmtd.lib ..\..\..\fftw-2.1.3\Win32\FFTW2st\Debug\FFTW2st.lib ..\..\..\fftw-2.1.3\Win32\RFFTW2st\Debug\RFFTW2st.lib wxd.lib xpmd.lib tiffd.lib zlibd.lib pngd.lib comctl32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib opengl32.lib glu32.lib htmlhelp.lib /nologo /subsystem:windows /incremental:yes /pdb:"Debug/ctsim.pdb" /debug /machine:I386 /out:"Debug/ctsim.exe" /pdbtype:sept /libpath:"\wx2.2.5\lib" .\Debug\backgroundmgr.obj @@ -37,10 +37,10 @@ winmm.lib rpcrt4.lib ws2_32.lib ../libctsim/Debug/libctsim.lib libcmtd.lib ..\.. \wx2.2.5\lib\zlibd.lib \wx2.2.5\lib\tiffd.lib ] -Creating command line "link.exe @C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP248.tmp" +Creating command line "link.exe @C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP25C.tmp"

Output Window

Compiling... -threadrecon.cpp +backgroundsupr.cpp Linking... diff --git a/src/backgroundsupr.cpp b/src/backgroundsupr.cpp index 2b8c049..04af1d6 100644 --- a/src/backgroundsupr.cpp +++ b/src/backgroundsupr.cpp @@ -9,7 +9,7 @@ ** This is part of the CTSim program ** Copyright (C) 1983-2001 Kevin Rosenberg ** -** $Id: backgroundsupr.cpp,v 1.2 2001/02/25 07:36:26 kevin Exp $ +** $Id: backgroundsupr.cpp,v 1.3 2001/02/25 08:00:57 kevin Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License (version 2) as @@ -84,6 +84,16 @@ BackgroundSupervisor::BackgroundSupervisor (wxFrame* pParentFrame, wxDocument* p BackgroundSupervisor::~BackgroundSupervisor() { + for (int i = 0; i < m_iNumThreads; i++) + if (m_vecpThreads[i]) { + m_vecpThreads[i]->Delete(); // sends Destroy message to workers + } + + while (m_iRunning > 0) { + Sleep(50); + ProcessPendingEvents(); + } + if (m_bBackgroundTaskAdded) { wxCommandEvent doneEvent (wxEVT_COMMAND_MENU_SELECTED, MSG_BACKGROUND_SUPERVISOR_REMOVE); doneEvent.SetClientData (this); @@ -100,23 +110,6 @@ BackgroundSupervisor::~BackgroundSupervisor() delete m_pDialogProgress; } -void -BackgroundSupervisor::deleteAnyWorkers() -{ - m_critsectThreadContainer.Enter(); - for (int i = 0; i < m_iNumThreads; i++) - if (m_vecpThreads[i]) { - m_vecpThreads[i]->Delete(); // sends Destroy message to workers - } - m_critsectThreadContainer.Leave(); - - while (m_iRunning > 0) { - Sleep(50); - ProcessPendingEvents(); - } -} - - bool BackgroundSupervisor::start() { @@ -174,7 +167,6 @@ void BackgroundSupervisor::OnCancel(wxCommandEvent& event) { m_bCancelled = true; - deleteAnyWorkers(); m_bDone = true; } @@ -212,9 +204,6 @@ BackgroundSupervisor::OnWorkerDone (wxCommandEvent& event) { m_iRunning--; wxASSERT (m_iRunning >= 0); - m_critsectThreadContainer.Enter(); - m_vecpThreads[event.GetInt()] = NULL; - m_critsectThreadContainer.Leave(); #ifdef DEBUG if (theApp->getVerboseLogging()) { @@ -233,13 +222,11 @@ void BackgroundSupervisor::OnWorkerFail (wxCommandEvent& event) { m_iRunning--; - m_critsectThreadContainer.Enter(); - m_vecpThreads[event.GetInt()] = NULL; - m_critsectThreadContainer.Leave(); wxCommandEvent eventLog( wxEVT_COMMAND_MENU_SELECTED, MAINMENU_LOG_EVENT ); eventLog.SetString( event.GetString() ); wxPostEvent( theApp->getMainFrame(), eventLog ); // send log event - onDone(); + wxCommandEvent dummy; + OnCancel(dummy); } diff --git a/src/backgroundsupr.h b/src/backgroundsupr.h index faae6e0..9058c59 100644 --- a/src/backgroundsupr.h +++ b/src/backgroundsupr.h @@ -9,7 +9,7 @@ ** This is part of the CTSim program ** Copyright (C) 1983-2001 Kevin Rosenberg ** -** $Id: backgroundsupr.h,v 1.1 2001/02/25 06:32:12 kevin Exp $ +** $Id: backgroundsupr.h,v 1.2 2001/02/25 08:00:57 kevin Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License (version 2) as @@ -56,7 +56,6 @@ private: typedef std::vector ThreadContainer; ThreadContainer m_vecpThreads; - wxCriticalSection m_critsectThreadContainer; wxFrame* m_pParentFrame; wxDocument* m_pDocument; const std::string m_strProcessTitle; @@ -99,7 +98,6 @@ public: { return NULL; } bool start(); - void deleteAnyWorkers(); virtual void onDone() {}; virtual void OnWorkerFail(wxCommandEvent& event); diff --git a/src/threadrecon.cpp b/src/threadrecon.cpp index 820b44b..75861c4 100644 --- a/src/threadrecon.cpp +++ b/src/threadrecon.cpp @@ -9,7 +9,7 @@ ** This is part of the CTSim program ** Copyright (C) 1983-2001 Kevin Rosenberg ** -** $Id: threadrecon.cpp,v 1.9 2001/02/25 07:36:26 kevin Exp $ +** $Id: threadrecon.cpp,v 1.10 2001/02/25 08:00:57 kevin Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License (version 2) as @@ -221,47 +221,53 @@ ReconstructorWorker::Entry () *m_pImageFile, m_pszFilterName, m_dFilterParam, m_pszFilterMethod, m_iZeropad, m_pszFilterGenerationName, m_pszInterpName, m_iInterpParam, m_pszBackprojectName, Trace::TRACE_NONE); - wxCommandEvent eventDone (wxEVT_COMMAND_MENU_SELECTED, BackgroundSupervisor::MSG_WORKER_THREAD_DONE); - eventDone.SetInt (m_iThread); // Send back thread# that has finished - - if (pReconstructor->fail()) { - wxString msg("Unable to make reconstructor: "); - msg += pReconstructor->failMessage().c_str(); + bool bFail = pReconstructor->fail(); + wxString failMsg; + if (bFail) { + failMsg = "Unable to make reconstructor: "; + failMsg += pReconstructor->failMessage().c_str(); wxCommandEvent event( wxEVT_COMMAND_MENU_SELECTED, MAINMENU_LOG_EVENT ); - event.SetString( msg ); + event.SetString( failMsg ); wxPostEvent( theApp->getMainFrame(), event ); - - wxPostEvent (m_pSupervisor, eventDone); - return reinterpret_cast(-1); } - - wxCommandEvent eventProgress (wxEVT_COMMAND_MENU_SELECTED, BackgroundSupervisor::MSG_WORKER_THREAD_UNIT_TICK); - - for (int iUnit = 0; iUnit < m_iNumUnits; iUnit++) { - if (TestDestroy()) { + else + { + wxCommandEvent eventProgress (wxEVT_COMMAND_MENU_SELECTED, BackgroundSupervisor::MSG_WORKER_THREAD_UNIT_TICK); + for (int iUnit = 0; iUnit < m_iNumUnits; iUnit++) { + if (TestDestroy()) { #ifdef DEBUG - if (theApp->getVerboseLogging()) { - wxString msg; - msg.Printf("Worker thread: Received destroy message at work unit #%d\n", iUnit); - wxCommandEvent event( wxEVT_COMMAND_MENU_SELECTED, MAINMENU_LOG_EVENT ); - event.SetString( msg ); - wxPostEvent( theApp->getMainFrame(), event ); - } + if (theApp->getVerboseLogging()) { + wxString msg; + msg.Printf("Worker thread: Received destroy message at work unit #%d\n", iUnit); + wxCommandEvent event( wxEVT_COMMAND_MENU_SELECTED, MAINMENU_LOG_EVENT ); + event.SetString( msg ); + wxPostEvent( theApp->getMainFrame(), event ); + } #endif - delete pReconstructor; - wxPostEvent (m_pSupervisor, eventDone); - - return reinterpret_cast(-1); + break; + } + pReconstructor->reconstructView (iUnit + m_iStartUnit, 1); + m_pSupervisor->AddPendingEvent (eventProgress); } - pReconstructor->reconstructView (iUnit + m_iStartUnit, 1); - m_pSupervisor->AddPendingEvent (eventProgress); + pReconstructor->postProcessing(); } - pReconstructor->postProcessing(); delete pReconstructor; - wxPostEvent (m_pSupervisor, eventDone); + if (bFail) { + wxCommandEvent eventFail (wxEVT_COMMAND_MENU_SELECTED, BackgroundSupervisor::MSG_WORKER_THREAD_FAIL); + eventFail.SetInt (m_iThread); // Send back thread# that has finished + eventFail.SetString (failMsg); + wxPostEvent (m_pSupervisor, eventFail); + } else { + wxCommandEvent eventDone (wxEVT_COMMAND_MENU_SELECTED, BackgroundSupervisor::MSG_WORKER_THREAD_DONE); + eventDone.SetInt (m_iThread); // Send back thread# that has finished + wxPostEvent (m_pSupervisor, eventDone); + } - return reinterpret_cast(0); + while (! TestDestroy()) + Sleep(100); + + return reinterpret_cast(0); } void -- 2.34.1