r607: *** empty log message ***
authorKevin M. Rosenberg <kevin@rosenberg.net>
Mon, 5 Mar 2001 17:26:46 +0000 (17:26 +0000)
committerKevin M. Rosenberg <kevin@rosenberg.net>
Mon, 5 Mar 2001 17:26:46 +0000 (17:26 +0000)
src/backgroundsupr.cpp
src/backgroundsupr.h
src/docs.cpp
src/docs.h
src/graph3dview.cpp
src/threadproj.cpp
src/threadraster.cpp
src/threadrecon.cpp

index 9eb806fda46d69f13f538ad5159222cdfed51f68..561009c8b97a368ae41aaf2eb3eeb79abab415f5 100644 (file)
@@ -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 ()
index 2ee7db6662ebd652b49a5cf94f9dd2c94be5af2a..ada1550f8c4e6ca85d314c75907ca2de55b4815a 100644 (file)
@@ -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<BackgroundWorkerThread*> 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();
index 6ea75a0509aed50a7664d80c68c84d6e7ecf6629..bd4e404416579ccc1cf924b4d3150ca16b8f6979 100644 (file)
@@ -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<BackgroundSupervisor*>(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<BackgroundSupervisor*>(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++)
index 5947b18490957931c9078f0fd22e0972034f74bc..7c41956b7dc2a8c312bdb821171fd69f6a51df5d 100644 (file)
@@ -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<BackgroundObject*> 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()
index 4295f4c9a3da128a61901d449082c83f4207a343..cb9d64f559fe52e3f2b55d80098476c96f646d5d 100644 (file)
@@ -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];
index 9927d0be17411c0aa429111c6b0497ef7a379b90..b44cc26110b45aa2a544861c32aa9404c56fa4bb 100644 (file)
@@ -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<wxThread::ExitCode>(0);
 }
 
index 3b90791c4b2275bfd6c4910b103fdb5f97c540c6..f1678ce613d79b0dd92416426e8d9e3f43b5b411 100644 (file)
@@ -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<wxThread::ExitCode>(0);
 }
index 0ec059bbcb2293be950c8731d8b29878deafe068..a3134a337d393f9abc1f707d19a78dced8039f55 100644 (file)
@@ -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<wxThread::ExitCode>(0);
 }