Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
more C++ish in EngineImpl
authorMartin Quinson <martin.quinson@ens-rennes.fr>
Mon, 14 Mar 2022 07:39:20 +0000 (08:39 +0100)
committerMartin Quinson <martin.quinson@ens-rennes.fr>
Mon, 14 Mar 2022 20:42:44 +0000 (21:42 +0100)
Move some stuff to the object destructor where it belongs.

There is still a lot to do in there before it's real C++ code...

src/kernel/EngineImpl.cpp
src/kernel/EngineImpl.hpp

index 7dcaf9b..f8bb4bc 100644 (file)
@@ -185,7 +185,15 @@ EngineImpl::~EngineImpl()
   for (auto const& kv : mailboxes_)
     delete kv.second;
 
-    /* Free the remaining data structures */
+  /* Kill all actors (but maestro) */
+  maestro_->kill_all();
+  run_all_actors();
+  empty_trash();
+
+  delete maestro_;
+  delete context_factory_;
+
+  /* Free the remaining data structures */
 #if SIMGRID_HAVE_MC
   xbt_dynar_free(&actors_vector_);
 #endif
@@ -307,18 +315,6 @@ void EngineImpl::shutdown()
     xbt_die("Bailing out to avoid that stop-before-start madness. Please fix your code.");
   }
 
-  /* Kill all actors (but maestro) */
-  instance_->maestro_->kill_all();
-  instance_->run_all_actors();
-  instance_->empty_trash();
-
-  /* Let's free maestro now */
-  delete instance_->maestro_;
-  instance_->maestro_ = nullptr;
-
-  /* Finish context module and SURF */
-  instance_->destroy_context_factory();
-
   while (not timer::kernel_timers().empty()) {
     delete timer::kernel_timers().top().second;
     timer::kernel_timers().pop();
index c28f6d5..0ddfc52 100644 (file)
@@ -97,11 +97,6 @@ public:
   context::ContextFactory* get_context_factory() const { return context_factory_; }
   void set_context_factory(context::ContextFactory* factory) { context_factory_ = factory; }
   bool has_context_factory() const { return context_factory_ != nullptr; }
-  void destroy_context_factory()
-  {
-    delete context_factory_;
-    context_factory_ = nullptr;
-  }
 
   void context_mod_init() const;
   /**