X-Git-Url: http://git.kpe.io/?p=ctsim.git;a=blobdiff_plain;f=src%2Fthreadrecon.cpp;h=e4bf3c5e558c249e7594113d027a6290a82f753d;hp=7f4e9518ba30566c16d0b577b2c08aafadc86b89;hb=130313545159177ab450ddd249a49096cfdb1376;hpb=15582f4ca80f519d7ddca580ff8cb852878fd2a2 diff --git a/src/threadrecon.cpp b/src/threadrecon.cpp index 7f4e951..e4bf3c5 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.18 2001/03/04 04:16:20 kevin Exp $ +** $Id: threadrecon.cpp,v 1.23 2001/03/09 03:54:25 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 @@ -55,10 +55,9 @@ ReconstructorSupervisorThread::ReconstructorSupervisorThread (ProjectionFileView const char* pszFilterName, double dFilterParam, const char* pszFilterMethod, int iZeropad, const char* pszFilterGenerationName, const char* pszInterpName, int iInterpParam, const char* pszBackprojectName, const char* const pszLabel) -: m_pProjView(pProjView), m_iNX(iNX), m_iNY(iNY), m_strFilterName(pszFilterName), m_dFilterParam(dFilterParam), +: SupervisorThread(), m_pProjView(pProjView), m_iNX(iNX), m_iNY(iNY), m_strFilterName(pszFilterName), m_dFilterParam(dFilterParam), m_strFilterMethod(pszFilterMethod), m_iZeropad(iZeropad), m_strFilterGenerationName(pszFilterGenerationName), - m_strInterpName(pszInterpName), m_iInterpParam(iInterpParam), m_strBackprojectName(pszBackprojectName), m_strLabel(pszLabel), - SupervisorThread() + m_strInterpName(pszInterpName), m_iInterpParam(iInterpParam), m_strBackprojectName(pszBackprojectName), m_strLabel(pszLabel) { } @@ -70,9 +69,8 @@ ReconstructorSupervisorThread::Entry() m_strInterpName.c_str(), m_iInterpParam, m_strBackprojectName.c_str(), m_strLabel.c_str()); reconSupervisor.start(); - while (! reconSupervisor.isDone() && ! reconSupervisor.fail()) { + while (! reconSupervisor.workersDone() && ! reconSupervisor.fail() && ! reconSupervisor.cancelled()) { Sleep(100); - Yield(); } if (reconSupervisor.fail()) { @@ -83,13 +81,11 @@ ReconstructorSupervisorThread::Entry() eventLog.SetString( msg ); wxPostEvent( theApp->getMainFrame(), eventLog ); // send log event } + if (! reconSupervisor.cancelled()) + reconSupervisor.onDone(); + reconSupervisor.deleteWorkers(); - while (! reconSupervisor.workersDeleted()) { - Sleep(50); - reconSupervisor.ProcessPendingEvents(); - } - - return reinterpret_cast(0); + return static_cast(0); } void @@ -108,15 +104,15 @@ ReconstructorSupervisor::ReconstructorSupervisor (SupervisorThread* pThread, Pro int iImageNX, int iImageNY, const char* pszFilterName, double dFilterParam, const char* pszFilterMethod, int iZeropad, const char* pszFilterGenerationName, const char* pszInterpName, int iInterpParam, const char* pszBackprojectName, const char* const pszLabel) - : m_pProjView(pProjView), m_pProjDoc(pProjView->GetDocument()), + : BackgroundSupervisor (pThread, pProjView->GetFrame(), pProjView->GetDocument(), "Reconstructing", pProjView->GetDocument()->getProjections().nView()), + m_pProjView(pProjView), m_pProjDoc(pProjView->GetDocument()), m_iImageNX(iImageNX), m_iImageNY(iImageNY), m_pszFilterName(pszFilterName), m_dFilterParam(dFilterParam), m_pszFilterMethod(pszFilterMethod), m_iZeropad(iZeropad), m_pszFilterGenerationName(pszFilterGenerationName), m_pszInterpName(pszInterpName), - m_iInterpParam(iInterpParam), m_pszBackprojectName(pszBackprojectName), m_pszLabel(pszLabel), - BackgroundSupervisor (pThread, pProjView->GetFrame(), pProjView->GetDocument(), "Reconstructing", pProjView->GetDocument()->getProjections().nView()) + m_iInterpParam(iInterpParam), m_pszBackprojectName(pszBackprojectName), m_pszLabel(pszLabel) { m_vecpChildImageFile.reserve (getNumWorkers()); - for (unsigned int iThread = 0; iThread < getNumWorkers(); iThread++) { + for (int iThread = 0; iThread < getNumWorkers(); iThread++) { m_vecpChildImageFile[iThread] = new ImageFile (m_iImageNX, m_iImageNY); } @@ -216,12 +212,12 @@ ReconstructorWorker::Entry () m_pszFilterGenerationName, m_pszInterpName, m_iInterpParam, m_pszBackprojectName, Trace::TRACE_NONE); bool bFail = pReconstructor->fail(); - wxString failMsg; + std::string failMsg; if (bFail) { failMsg = "Unable to make reconstructor: "; failMsg += pReconstructor->failMessage().c_str(); wxCommandEvent event( wxEVT_COMMAND_MENU_SELECTED, MAINMENU_LOG_EVENT ); - event.SetString( failMsg ); + event.SetString( failMsg.c_str() ); wxPostEvent( theApp->getMainFrame(), event ); } else @@ -241,21 +237,16 @@ ReconstructorWorker::Entry () break; } pReconstructor->reconstructView (iUnit + m_iStartUnit, 1); - m_pSupervisor->AddPendingEvent (eventProgress); + m_pSupervisor->onWorkerUnitTick(); } pReconstructor->postProcessing(); } delete pReconstructor; 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); + m_pSupervisor->onWorkerFail (m_iThread, failMsg); } 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); + m_pSupervisor->onWorkerDone (m_iThread); } while (! TestDestroy())