Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Somewhat redo commit df93dfaab8d79f5e08088aedc95dd2712cef4c70.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Sun, 19 Sep 2021 14:20:22 +0000 (16:20 +0200)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Sun, 19 Sep 2021 17:01:05 +0000 (19:01 +0200)
Avoids a second initialization of Engine after the end.
See e.g. with teshsuite/s4u/actor-suspend

include/simgrid/s4u/Engine.hpp
src/kernel/EngineImpl.hpp
src/kernel/actor/ActorImpl.cpp

index fdffcc1..4e571bb 100644 (file)
@@ -51,6 +51,7 @@ public:
   /** @brief Retrieve the engine singleton */
   static s4u::Engine* get_instance();
   static s4u::Engine* get_instance(int* argc, char** argv);
+  static bool has_instance() { return instance_ != nullptr; }
 
   void load_platform(const std::string& platf) const;
 
index 1676986..3cd04d4 100644 (file)
@@ -125,6 +125,7 @@ public:
   /** @brief Get list of all models managed by this engine */
   const std::vector<resource::Model*>& get_all_models() const { return models_; }
 
+  static bool has_instance() { return s4u::Engine::has_instance(); }
   static EngineImpl* get_instance() { return s4u::Engine::get_instance()->pimpl; }
   static EngineImpl* get_instance(int* argc, char** argv) { return s4u::Engine::get_instance(argc, argv)->pimpl; }
 
index d3b4ebf..f50964b 100644 (file)
@@ -73,7 +73,7 @@ ActorImpl::ActorImpl(xbt::string name, s4u::Host* host) : host_(host), name_(std
 
 ActorImpl::~ActorImpl()
 {
-  if (not EngineImpl::get_instance()->is_maestro(this))
+  if (EngineImpl::has_instance() && not EngineImpl::get_instance()->is_maestro(this))
     s4u::Actor::on_destruction(*get_ciface());
 }