Manta Interactive Ray Tracer Development Mailing List

Text archives Help


[Manta] r2015 - trunk/Engine/Control


Chronological Thread 
  • From: boulos@sci.utah.edu
  • To: manta@sci.utah.edu
  • Subject: [Manta] r2015 - trunk/Engine/Control
  • Date: Mon, 28 Jan 2008 19:56:14 -0700 (MST)

Author: boulos
Date: Mon Jan 28 19:56:13 2008
New Revision: 2015

Modified:
   trunk/Engine/Control/RTRT.cc
Log:
Engine/Control/RTRT.cc

 blockUntilFinished didn't actually perform to spec. I've changed it
 so that it waits until thread 0 actually flags Manta as no longer
 running, and when that happens join all running threads (which should
 be either 1 thread or 0 threads). Afterwards, I remove thread 0 as
 well (so on future calls to blockUntilFinished, it'll look at the
 lock, see nobody around and exit having effectively blocked until
 finished)


Modified: trunk/Engine/Control/RTRT.cc
==============================================================================
--- trunk/Engine/Control/RTRT.cc        (original)
+++ trunk/Engine/Control/RTRT.cc        Mon Jan 28 19:56:13 2008
@@ -524,11 +524,26 @@
 
 }
 
+// NOTE(boulos): This function can be called multiple times
 void RTRT::blockUntilFinished()
 {
-  ASSERT(running);
-  ASSERT(workers.size()>0);
-  workers[0]->join();
+  while (1) {
+    runningLock.lock();
+    if (running == false) {
+      // Now that nobody is running, workers.size() should be exactly 1
+      // (since we've already brought down all other threads) or should be
+      // 0 upon future calls into this function.
+      ASSERT(workers.size() == 0 ||
+             workers.size() == 1);
+      for (size_t i = 0; i < workers.size(); i++) {
+        workers[i]->join();
+      }
+      workers.resize(0);
+      runningLock.unlock();
+      break;
+    }
+    runningLock.unlock();
+  }
 }
 
 void RTRT::doPreprocess(int proc, int numProcs) {
@@ -593,8 +608,6 @@
     } else {
       // Lock the update graph and see if a leaf node can be expanded
       // into more work
-      //cerr << "Work queue failed to give out work 
(update_work_queue.size() = " << update_work_queue->tasks.size() << std::endl;
-
       Object* object = NULL;
       update_graph->lock();
       ObjectUpdateGraph::leaf_iterator leaf_it = 
update_graph->leaf_nodes.begin();
@@ -675,7 +688,7 @@
         // Time is stopped - leave the frame state where it is
       } else {
         animFrameState.animationFrameNumber++;
-      
+
         switch(timeMode){
         case RealTime:
           animFrameState.shutter_open = animFrameState.shutter_close;




  • [Manta] r2015 - trunk/Engine/Control, boulos, 01/28/2008

Archive powered by MHonArc 2.6.16.

Top of page