Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of https://framagit.org/simgrid/simgrid
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Sat, 2 Feb 2019 08:45:46 +0000 (09:45 +0100)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Sat, 2 Feb 2019 08:45:46 +0000 (09:45 +0100)
src/kernel/activity/ActivityImpl.cpp
src/kernel/activity/ActivityImpl.hpp
src/kernel/activity/ExecImpl.cpp
src/kernel/activity/ExecImpl.hpp
src/kernel/activity/IoImpl.hpp
src/kernel/activity/SleepImpl.cpp
src/kernel/activity/SleepImpl.hpp
src/kernel/activity/SynchroRaw.cpp
src/kernel/activity/SynchroRaw.hpp
src/simix/ActorImpl.cpp
src/simix/smx_synchro.cpp

index c1bb685..ff1cb4b 100644 (file)
@@ -9,9 +9,6 @@ namespace simgrid {
 namespace kernel {
 namespace activity {
 
-ActivityImpl::ActivityImpl()  = default;
-ActivityImpl::~ActivityImpl() = default;
-
 // boost::intrusive_ptr<Activity> support:
 void intrusive_ptr_add_ref(simgrid::kernel::activity::ActivityImpl* activity)
 {
index 375d21c..8f1267f 100644 (file)
@@ -21,12 +21,14 @@ namespace activity {
 
 class XBT_PUBLIC ActivityImpl {
 public:
-  ActivityImpl();
+  ActivityImpl() = default;
   explicit ActivityImpl(std::string name) : name_(name) {}
-  virtual ~ActivityImpl();
+  explicit ActivityImpl(std::string name, resource::Action* surf_action) : name_(name), surf_action_(surf_action) {}
+  virtual ~ActivityImpl() = default;
   e_smx_state_t state_ = SIMIX_WAITING; /* State of the activity */
   std::string name_;                    /* Activity name if any */
   std::list<smx_simcall_t> simcalls_;   /* List of simcalls waiting for this activity */
+  resource::Action* surf_action_ = nullptr;
 
   virtual void suspend() = 0;
   virtual void resume()  = 0;
index b959baa..0edc385 100644 (file)
@@ -17,7 +17,7 @@ XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix_process);
 
 simgrid::kernel::activity::ExecImpl::ExecImpl(std::string name, resource::Action* surf_action,
                                               resource::Action* timeout_detector, s4u::Host* host)
-    : ActivityImpl(name), host_(host), surf_action_(surf_action), timeout_detector_(timeout_detector)
+    : ActivityImpl(name, surf_action), host_(host), timeout_detector_(timeout_detector)
 {
   this->state_ = SIMIX_RUNNING;
 
index 00e0b85..9ad4b5e 100644 (file)
@@ -32,7 +32,6 @@ public:
 
   /* The host where the execution takes place. nullptr means this is a parallel exec (and only surf knows the hosts) */
   s4u::Host* host_ = nullptr;
-  resource::Action* surf_action_; /* The Surf execution action encapsulated */
 private:
   resource::Action* timeout_detector_ = nullptr;
 
index 55619bf..e61d9ea 100644 (file)
@@ -17,7 +17,7 @@ namespace activity {
 class XBT_PUBLIC IoImpl : public ActivityImpl {
 public:
   ~IoImpl() override;
-  explicit IoImpl(std::string name, simgrid::surf::StorageImpl* storage);
+  explicit IoImpl(std::string name, surf::StorageImpl* storage);
 
   void start(sg_size_t size, simgrid::s4u::Io::OpType type);
   void suspend() override;
@@ -27,8 +27,7 @@ public:
   double get_remaining();
   sg_size_t get_performed_ioops() { return performed_ioops_; }
 
-  simgrid::surf::StorageImpl* storage_            = nullptr;
-  simgrid::kernel::resource::Action* surf_action_ = nullptr;
+  surf::StorageImpl* storage_                     = nullptr;
   sg_size_t performed_ioops_                      = 0;
   static simgrid::xbt::signal<void(kernel::activity::IoImplPtr)> on_start;
   static simgrid::xbt::signal<void(kernel::activity::IoImplPtr)> on_completion;
index e683dd5..fa13818 100644 (file)
@@ -19,12 +19,12 @@ XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix_process);
 
 void simgrid::kernel::activity::SleepImpl::suspend()
 {
-  surf_sleep->suspend();
+  surf_action_->suspend();
 }
 
 void simgrid::kernel::activity::SleepImpl::resume()
 {
-  surf_sleep->resume();
+  surf_action_->resume();
 }
 
 void simgrid::kernel::activity::SleepImpl::post()
@@ -41,7 +41,7 @@ void simgrid::kernel::activity::SleepImpl::post()
           std::make_exception_ptr(simgrid::HostFailureException(XBT_THROW_POINT, "Host failed")));
     }
 
-    switch (surf_sleep->get_state()) {
+    switch (surf_action_->get_state()) {
       case simgrid::kernel::resource::Action::State::FAILED:
         simcall->issuer->context_->iwannadie = true;
         result                               = SIMIX_FAILED;
index dbc0a7d..9128912 100644 (file)
@@ -19,8 +19,7 @@ public:
   void resume() override;
   void post() override;
 
-  sg_host_t host           = nullptr; /* The host that is sleeping */
-  simgrid::kernel::resource::Action* surf_sleep = nullptr; /* The Surf sleeping action encapsulated */
+  sg_host_t host                 = nullptr;
 };
 }
 }
index 9b9db4f..3287a00 100644 (file)
@@ -12,7 +12,7 @@ XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix_synchro);
 
 simgrid::kernel::activity::RawImpl::~RawImpl()
 {
-  sleep->unref();
+  surf_action_->unref();
 }
 void simgrid::kernel::activity::RawImpl::suspend()
 {
@@ -27,9 +27,9 @@ void simgrid::kernel::activity::RawImpl::resume()
 void simgrid::kernel::activity::RawImpl::post()
 {
   XBT_IN("(%p)",this);
-  if (sleep->get_state() == simgrid::kernel::resource::Action::State::FAILED)
+  if (surf_action_->get_state() == simgrid::kernel::resource::Action::State::FAILED)
     state_ = SIMIX_FAILED;
-  else if (sleep->get_state() == simgrid::kernel::resource::Action::State::FINISHED)
+  else if (surf_action_->get_state() == simgrid::kernel::resource::Action::State::FINISHED)
     state_ = SIMIX_SRC_TIMEOUT;
 
   SIMIX_synchro_finish(this);
index d9a38c2..c96dd4a 100644 (file)
@@ -20,10 +20,7 @@ public:
   void suspend() override;
   void resume() override;
   void post() override;
-
-  simgrid::kernel::resource::Action* sleep = nullptr;
-  };
-
+};
 }}} // namespace simgrid::kernel::activity
 
 #endif
index 2e2065b..6560ccd 100644 (file)
@@ -195,8 +195,8 @@ smx_activity_t ActorImpl::sleep(double duration)
 
   simgrid::kernel::activity::SleepImpl* synchro = new simgrid::kernel::activity::SleepImpl();
   synchro->host                                 = host_;
-  synchro->surf_sleep                           = host_->pimpl_cpu->sleep(duration);
-  synchro->surf_sleep->set_data(synchro);
+  synchro->surf_action_                         = host_->pimpl_cpu->sleep(duration);
+  synchro->surf_action_->set_data(synchro);
   XBT_DEBUG("Create sleep synchronization %p", synchro);
 
   return synchro;
@@ -462,8 +462,8 @@ void SIMIX_process_kill(smx_actor_t actor, smx_actor_t issuer)
       if (i != actor->waiting_synchro->simcalls_.end())
         actor->waiting_synchro->simcalls_.remove(&actor->simcall);
     } else if (sleep != nullptr) {
-      if (sleep->surf_sleep)
-        sleep->surf_sleep->cancel();
+      if (sleep->surf_action_)
+        sleep->surf_action_->cancel();
       sleep->post();
     } else if (raw != nullptr) {
       SIMIX_synchro_stop_waiting(actor, &actor->simcall);
@@ -626,8 +626,8 @@ smx_activity_t SIMIX_process_join(smx_actor_t issuer, smx_actor_t process, doubl
   SIMIX_process_on_exit(process,
                         [](int, void* arg) {
                           auto sleep = static_cast<simgrid::kernel::activity::SleepImpl*>(arg);
-                          if (sleep->surf_sleep)
-                            sleep->surf_sleep->finish(simgrid::kernel::resource::Action::State::FINISHED);
+                          if (sleep->surf_action_)
+                            sleep->surf_action_->finish(simgrid::kernel::resource::Action::State::FINISHED);
                           intrusive_ptr_release(sleep);
                         },
                         res.get());
@@ -653,9 +653,9 @@ void SIMIX_process_sleep_destroy(smx_activity_t synchro)
   simgrid::kernel::activity::SleepImplPtr sleep =
       boost::dynamic_pointer_cast<simgrid::kernel::activity::SleepImpl>(synchro);
 
-  if (sleep->surf_sleep) {
-    sleep->surf_sleep->unref();
-    sleep->surf_sleep = nullptr;
+  if (sleep->surf_action_) {
+    sleep->surf_action_->unref();
+    sleep->surf_action_ = nullptr;
   }
 }
 
index 7fa94bf..11c4716 100644 (file)
@@ -20,8 +20,8 @@ smx_activity_t SIMIX_synchro_wait(sg_host_t smx_host, double timeout)
 
   simgrid::kernel::activity::RawImplPtr sync =
       simgrid::kernel::activity::RawImplPtr(new simgrid::kernel::activity::RawImpl());
-  sync->sleep                          = smx_host->pimpl_cpu->sleep(timeout);
-  sync->sleep->set_data(sync.get());
+  sync->surf_action_ = smx_host->pimpl_cpu->sleep(timeout);
+  sync->surf_action_->set_data(sync.get());
   XBT_OUT();
   return sync;
 }