From d77c9d135405e077047ef3426a54470c144cdd34 Mon Sep 17 00:00:00 2001 From: "Kevin M. Rosenberg" Date: Mon, 5 Mar 2001 17:26:46 +0000 Subject: [PATCH] r607: *** empty log message *** --- src/backgroundsupr.cpp | 29 +++++++++-------------------- src/backgroundsupr.h | 9 ++++----- src/docs.cpp | 22 +++++----------------- src/docs.h | 10 +++++----- src/graph3dview.cpp | 6 +++--- src/threadproj.cpp | 6 +----- src/threadraster.cpp | 6 +----- src/threadrecon.cpp | 6 +----- 8 files changed, 29 insertions(+), 65 deletions(-) diff --git a/src/backgroundsupr.cpp b/src/backgroundsupr.cpp index 9eb806f..561009c 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.12 2001/03/04 22:30:19 kevin Exp $ +** $Id: backgroundsupr.cpp,v 1.13 2001/03/05 17:26:46 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 @@ -52,10 +52,10 @@ END_EVENT_TABLE() -BackgroundSupervisor::BackgroundSupervisor (SupervisorThread* pMyThread, wxFrame* pParentFrame, wxDocument* pDocument, const char* const pszProcessTitle, int iTotalUnits) +BackgroundSupervisor::BackgroundSupervisor (SupervisorThread* pMyThread, wxFrame* pParentFrame, BackgroundProcessingDocument* pDocument, const char* const pszProcessTitle, int iTotalUnits) : wxEvtHandler(), m_pMyThread(pMyThread), m_pParentFrame(pParentFrame), m_pDocument(pDocument), m_strProcessTitle(pszProcessTitle), m_iTotalUnits(iTotalUnits), m_iNumThreads(0), m_bDone(false), m_bFail(false), m_bCancelled(false), m_iRunning(0), - m_pTimer(NULL), m_bBackgroundTaskAdded(false), m_bWorkersDeleted(false) + m_pTimer(NULL), m_bWorkersDeleted(false) { m_iNumThreads = theApp->getNumberCPU(); // ++m_iNumThreads; @@ -68,16 +68,11 @@ BackgroundSupervisor::BackgroundSupervisor (SupervisorThread* pMyThread, wxFrame BackgroundSupervisor::~BackgroundSupervisor() { - if (m_bBackgroundTaskAdded) { - wxCommandEvent doneEvent (wxEVT_COMMAND_MENU_SELECTED, MSG_BACKGROUND_SUPERVISOR_REMOVE); - doneEvent.SetClientData (this); - wxPostEvent (theApp->getBackgroundManager(), doneEvent); - wxPostEvent (m_pDocument, doneEvent); - } + wxCommandEvent doneEvent (wxEVT_COMMAND_MENU_SELECTED, MSG_BACKGROUND_SUPERVISOR_REMOVE); + doneEvent.SetClientData (this); + wxPostEvent (theApp->getBackgroundManager(), doneEvent); - while (m_bBackgroundTaskAdded) { - m_pMyThread->Sleep(50); - } + m_pDocument->removeBackgroundSupervisor (this); delete m_pTimer; } @@ -138,8 +133,8 @@ BackgroundSupervisor::start() addTaskEvent.SetInt (m_iTotalUnits); addTaskEvent.SetClientData (this); wxPostEvent (theApp->getBackgroundManager(), addTaskEvent); - wxPostEvent (m_pDocument, addTaskEvent); - m_bBackgroundTaskAdded = true; + + m_pDocument->addBackgroundSupervisor (this); m_iRunning = m_iNumThreads; m_iUnitsDone = 0; @@ -157,12 +152,6 @@ BackgroundSupervisor::onCancel() m_bDone = true; } -void -BackgroundSupervisor::onAckDocumentRemove() -{ - m_bBackgroundTaskAdded = false; -} - void BackgroundSupervisor::onWorkerUnitTick () diff --git a/src/backgroundsupr.h b/src/backgroundsupr.h index 2ee7db6..ada1550 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.8 2001/03/04 22:30:19 kevin Exp $ +** $Id: backgroundsupr.h,v 1.9 2001/03/05 17:26:46 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 @@ -49,6 +49,7 @@ public: // Pure virtual class for BackgroundSupervisor that can communication // with BackgroundManager via messages class BackgroundWorkerThread; +class BackgroundProcessingDocument; class BackgroundSupervisor : public wxEvtHandler { private: @@ -56,7 +57,7 @@ private: SupervisorThread* m_pMyThread; wxFrame* m_pParentFrame; - wxDocument* m_pDocument; + BackgroundProcessingDocument* m_pDocument; const std::string m_strProcessTitle; const unsigned int m_iTotalUnits; @@ -68,7 +69,6 @@ private: volatile int m_iRunning; unsigned int m_iUnitsDone; Timer* m_pTimer; - bool m_bBackgroundTaskAdded; bool m_bWorkersDeleted; typedef std::vector ThreadContainer; @@ -89,7 +89,7 @@ public: MSG_WORKER_THREAD_FAIL = 7507, // sent by workers when they fail }; - BackgroundSupervisor (SupervisorThread* pMyThread, wxFrame* pParentFrame, wxDocument* pDocument, const char* const pszProcessTitle, + BackgroundSupervisor (SupervisorThread* pMyThread, wxFrame* pParentFrame, BackgroundProcessingDocument* pDocument, const char* const pszProcessTitle, int iTotalUnits); BackgroundSupervisor () @@ -105,7 +105,6 @@ public: virtual void onDone() {}; virtual void onCancel(); - virtual void onAckDocumentRemove(); virtual void onWorkerFail(int iThread, std::string strFailMessage); virtual void onWorkerUnitTick(); diff --git a/src/docs.cpp b/src/docs.cpp index 6ea75a0..bd4e404 100644 --- a/src/docs.cpp +++ b/src/docs.cpp @@ -9,7 +9,7 @@ ** This is part of the CTSim program ** Copyright (c) 1983-2001 Kevin Rosenberg ** -** $Id: docs.cpp,v 1.32 2001/03/05 15:10:58 kevin Exp $ +** $Id: docs.cpp,v 1.33 2001/03/05 17:26:46 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 @@ -130,30 +130,20 @@ ImageFileDocument::Revert () IMPLEMENT_DYNAMIC_CLASS(BackgroundProcessingDocument, wxDocument) BEGIN_EVENT_TABLE(BackgroundProcessingDocument, wxDocument) -#ifdef CTSIM_THREADS -EVT_MENU(BackgroundSupervisor::MSG_BACKGROUND_SUPERVISOR_ADD, BackgroundProcessingDocument::OnAddBackground) -EVT_MENU(BackgroundSupervisor::MSG_BACKGROUND_SUPERVISOR_REMOVE, BackgroundProcessingDocument::OnRemoveBackground) -#endif END_EVENT_TABLE() -#ifdef CTSIM_TREADS +#ifdef HAVE_WXTHREADS void -BackgroundProcessingDocument::OnAddBackground (wxCommandEvent& event) +BackgroundProcessingDocument::addBackgroundSupervisor (BackgroundSupervisor* pSupervisor) { - BackgroundSupervisor* pSupervisor = reinterpret_cast(event.GetClientData()); - wxASSERT (pSupervisor != NULL); - wxCriticalSectionLocker locker (m_criticalSection); if (pSupervisor) m_vecpBackgroundSupervisors.push_back (pSupervisor); } void -BackgroundProcessingDocument::OnRemoveBackground (wxCommandEvent& event) +BackgroundProcessingDocument::removeBackgroundSupervisor (BackgroundSupervisor* pSupervisor) { - BackgroundSupervisor* pSupervisor = reinterpret_cast(event.GetClientData()); - wxASSERT (pSupervisor != NULL); - m_criticalSection.Enter(); bool bFound = false; for (BackgroundContainer::iterator i = m_vecpBackgroundSupervisors.begin(); @@ -168,15 +158,13 @@ BackgroundProcessingDocument::OnRemoveBackground (wxCommandEvent& event) if (! bFound) sys_error (ERR_SEVERE, "Could not find background task [OnRemoveBackground]"); - - pSupervisor->onAckDocumentRemove(); } #endif void BackgroundProcessingDocument::cancelRunningTasks() { -#ifdef CTSIM_THREADS +#ifdef HAVE_WXTHREADS m_criticalSection.Enter(); for (BackgroundContainer::iterator i = m_vecpBackgroundSupervisors.begin(); i != m_vecpBackgroundSupervisors.end(); i++) diff --git a/src/docs.h b/src/docs.h index 5947b18..7c41956 100644 --- a/src/docs.h +++ b/src/docs.h @@ -9,7 +9,7 @@ ** This is part of the CTSim program ** Copyright (c) 1983-2001 Kevin Rosenberg ** -** $Id: docs.h,v 1.27 2001/03/05 15:10:58 kevin Exp $ +** $Id: docs.h,v 1.28 2001/03/05 17:26:46 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 @@ -90,7 +90,7 @@ class BackgroundProcessingDocument : public wxDocument { private: DECLARE_DYNAMIC_CLASS(BackgroundProcessingDocument) -#ifdef CTSIM_THREADS +#ifdef HAVE_WXTHREADS typedef BackgroundSupervisor BackgroundObject; typedef std::vector BackgroundContainer; BackgroundContainer m_vecpBackgroundSupervisors; @@ -103,9 +103,9 @@ public: {} void cancelRunningTasks(); -#ifdef CTSIM_THREADS - void OnAddBackground (wxCommandEvent& event); - void OnRemoveBackground (wxCommandEvent& event); +#ifdef HAVE_WXTHREADS + void addBackgroundSupervisor (BackgroundSupervisor* pSupervisor); + void removeBackgroundSupervisor (BackgroundSupervisor* pSupervisor); #endif DECLARE_EVENT_TABLE() diff --git a/src/graph3dview.cpp b/src/graph3dview.cpp index 4295f4c..cb9d64f 100644 --- a/src/graph3dview.cpp +++ b/src/graph3dview.cpp @@ -9,7 +9,7 @@ ** This is part of the CTSim program ** Copyright (c) 1983-2001 Kevin Rosenberg ** -** $Id: graph3dview.cpp,v 1.16 2001/03/04 03:14:47 kevin Exp $ +** $Id: graph3dview.cpp,v 1.17 2001/03/05 17:26:46 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 @@ -579,8 +579,8 @@ Graph3dFileView::OnUpdate (wxView *WXUNUSED(sender), wxObject *WXUNUSED(hint) ) if (! GetDocument()) return; - int nx = GetDocument()->nx(); - int ny = GetDocument()->ny(); + unsigned int nx = GetDocument()->nx(); + unsigned int ny = GetDocument()->ny(); const ImageFileArrayConst v = GetDocument()->getArray(); if (v != NULL && nx != 0 && ny != 0) { double min = v[0][0]; diff --git a/src/threadproj.cpp b/src/threadproj.cpp index 9927d0b..b44cc26 100644 --- a/src/threadproj.cpp +++ b/src/threadproj.cpp @@ -9,7 +9,7 @@ ** This is part of the CTSim program ** Copyright (C) 1983-2001 Kevin Rosenberg ** -** $Id: threadproj.cpp,v 1.13 2001/03/04 22:30:20 kevin Exp $ +** $Id: threadproj.cpp,v 1.14 2001/03/05 17:26:46 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 @@ -87,10 +87,6 @@ ProjectorSupervisorThread::Entry() projSupervisor.onDone(); projSupervisor.deleteWorkers(); - while (! projSupervisor.workersDeleted()) { - Sleep(50); - } - return reinterpret_cast(0); } diff --git a/src/threadraster.cpp b/src/threadraster.cpp index 3b90791..f1678ce 100644 --- a/src/threadraster.cpp +++ b/src/threadraster.cpp @@ -9,7 +9,7 @@ ** This is part of the CTSim program ** Copyright (C) 1983-2001 Kevin Rosenberg ** -** $Id: threadraster.cpp,v 1.8 2001/03/04 22:30:20 kevin Exp $ +** $Id: threadraster.cpp,v 1.9 2001/03/05 17:26:46 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 @@ -86,10 +86,6 @@ RasterizerSupervisorThread::Entry() if (! pRasterSupervisor->cancelled()) pRasterSupervisor->onDone(); pRasterSupervisor->deleteWorkers(); - while (! pRasterSupervisor->workersDeleted()) { - Sleep(50); - } - delete pRasterSupervisor; return reinterpret_cast(0); } diff --git a/src/threadrecon.cpp b/src/threadrecon.cpp index 0ec059b..a3134a3 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.20 2001/03/04 22:30:20 kevin Exp $ +** $Id: threadrecon.cpp,v 1.21 2001/03/05 17:26:46 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 @@ -86,10 +86,6 @@ ReconstructorSupervisorThread::Entry() reconSupervisor.onDone(); reconSupervisor.deleteWorkers(); - while (! reconSupervisor.workersDeleted()) { - Sleep(50); - } - return reinterpret_cast(0); } -- 2.34.1