Revision: 8512
          http://playerstage.svn.sourceforge.net/playerstage/?rev=8512&view=rev
Author:   hsujohnhsu
Date:     2010-01-15 09:51:24 +0000 (Fri, 15 Jan 2010)

Log Message:
-----------
added another mutex for model deletion

Modified Paths:
--------------
    code/gazebo/trunk/server/Simulator.cc
    code/gazebo/trunk/server/Simulator.hh

Modified: code/gazebo/trunk/server/Simulator.cc
===================================================================
--- code/gazebo/trunk/server/Simulator.cc       2010-01-15 09:49:23 UTC (rev 
8511)
+++ code/gazebo/trunk/server/Simulator.cc       2010-01-15 09:51:24 UTC (rev 
8512)
@@ -74,7 +74,8 @@
   selectedEntity(NULL),
   selectedBody(NULL)
 {
-  this->mutex = new boost::recursive_mutex();
+  this->render_mutex = new boost::recursive_mutex();
+  this->model_delete_mutex = new boost::recursive_mutex();
   this->startTime = this->GetWallTime();
 }
 
@@ -95,12 +96,18 @@
     this->xmlFile = NULL;
   }
 
-  if (this->mutex)
+  if (this->render_mutex)
   {
-    delete this->mutex;
-    this->mutex = NULL;
+    delete this->render_mutex;
+    this->render_mutex = NULL;
   }
 
+  if (this->model_delete_mutex)
+  {
+    delete this->model_delete_mutex;
+    this->model_delete_mutex = NULL;
+  }
+
   if (this->gui)
   {
     delete this->gui;
@@ -356,13 +363,14 @@
       if (this->renderEngineEnabled)
         OgreAdaptor::Instance()->UpdateCameras();
 
+      if (this->renderEngineEnabled)
+        World::Instance()->GraphicsUpdate();
+
       currTime = this->GetWallTime();
 
       World::Instance()->ProcessEntitiesToLoad();
+      World::Instance()->ProcessEntitiesToDelete();
 
-      if (this->renderEngineEnabled)
-        World::Instance()->GraphicsUpdate();
-
       if (currTime - lastTime < 1/freq)
       {
         Time sleepTime = ( Time(1.0/freq) - (currTime - lastTime));
@@ -410,7 +418,7 @@
 /// Set whether the simulation is paused
 void Simulator::SetPaused(bool p)
 {
-  boost::recursive_mutex::scoped_lock lock(*this->mutex);
+  boost::recursive_mutex::scoped_lock lock(*this->GetMRMutex());
 
   if (this->pause == p)
     return;
@@ -480,7 +488,7 @@
 
////////////////////////////////////////////////////////////////////////////////
 void Simulator::SetStepInc(bool step)
 {
-  boost::recursive_mutex::scoped_lock lock(*this->mutex);
+  boost::recursive_mutex::scoped_lock lock(*this->GetMRMutex());
   this->stepInc = step;
 }
 
@@ -653,7 +661,8 @@
     lastTime = this->GetRealTime();
 
     {
-      boost::recursive_mutex::scoped_lock lock(*this->mutex);
+      boost::recursive_mutex::scoped_lock lock(*this->GetMRMutex());
+      boost::recursive_mutex::scoped_lock 
model_delete_lock(*this->GetMDMutex());
       world->Update();
     }
 
@@ -712,10 +721,17 @@
 /// Get the simulator mutex
 boost::recursive_mutex *Simulator::GetMRMutex()
 {
-  return this->mutex;
+  return this->render_mutex;
 }
 
 
////////////////////////////////////////////////////////////////////////////////
+/// Get the simulator mutex
+boost::recursive_mutex *Simulator::GetMDMutex()
+{
+  return this->model_delete_mutex;
+}
+
+////////////////////////////////////////////////////////////////////////////////
 /// Get the state of the simulation
 Simulator::State Simulator::GetState() const
 {

Modified: code/gazebo/trunk/server/Simulator.hh
===================================================================
--- code/gazebo/trunk/server/Simulator.hh       2010-01-15 09:49:23 UTC (rev 
8511)
+++ code/gazebo/trunk/server/Simulator.hh       2010-01-15 09:51:24 UTC (rev 
8512)
@@ -171,9 +171,12 @@
     /// \brief Get the body that contains the entity
     public: Body *GetParentBody( Entity *entity ) const;
 
-    /// \brief Get the simulator mutex
+    /// \brief Get the simulator mutex for rendering lock
     public:boost::recursive_mutex *GetMRMutex();
 
+    /// \brief Get the simulator mutex for model deletion lock
+    public:boost::recursive_mutex *GetMDMutex();
+
     /// \brief Get the state of the simulation
     public: State GetState() const;
 
@@ -245,7 +248,8 @@
     /// Thread in which to run the gui
     private: boost::thread *physicsThread;
 
-    private: boost::recursive_mutex *mutex;
+    private: boost::recursive_mutex *render_mutex;
+    private: boost::recursive_mutex *model_delete_mutex;
 
     private: State state;
 


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
Throughout its 18-year history, RSA Conference consistently attracts the
world's best and brightest in the field, creating opportunities for Conference
attendees to learn about information security's most important issues through
interactions with peers, luminaries and emerging and established companies.
http://p.sf.net/sfu/rsaconf-dev2dev
_______________________________________________
Playerstage-commit mailing list
Playerstage-commit@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/playerstage-commit

Reply via email to