Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
let base class dtor deal with surf action
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Thu, 14 Mar 2019 13:07:37 +0000 (14:07 +0100)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Thu, 14 Mar 2019 13:07:37 +0000 (14:07 +0100)
For CommImpl, it seems that unref() is called too late so keep the
current dtor

src/kernel/activity/ActivityImpl.cpp
src/kernel/activity/ActivityImpl.hpp
src/kernel/activity/ExecImpl.cpp
src/kernel/activity/ExecImpl.hpp
src/kernel/activity/IoImpl.cpp
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

index 5b5c614..757667b 100644 (file)
@@ -11,6 +11,15 @@ namespace simgrid {
 namespace kernel {
 namespace activity {
 
 namespace kernel {
 namespace activity {
 
+ActivityImpl::~ActivityImpl()
+{
+  if (surf_action_) {
+    surf_action_->unref();
+    XBT_DEBUG("Destroy activity %p", this);
+    surf_action_ = nullptr;
+  }
+}
+
 void ActivityImpl::suspend()
 {
   if (surf_action_ == nullptr)
 void ActivityImpl::suspend()
 {
   if (surf_action_ == nullptr)
index 58e146c..ffb0231 100644 (file)
@@ -24,7 +24,7 @@ class XBT_PUBLIC ActivityImpl {
 public:
   ActivityImpl() = default;
   explicit ActivityImpl(const std::string& name) : name_(name) {}
 public:
   ActivityImpl() = default;
   explicit ActivityImpl(const std::string& name) : name_(name) {}
-  virtual ~ActivityImpl() = default;
+  virtual ~ActivityImpl();
   e_smx_state_t state_ = SIMIX_WAITING; /* State of the activity */
   std::list<smx_simcall_t> simcalls_;   /* List of simcalls waiting for this activity */
   resource::Action* surf_action_ = nullptr;
   e_smx_state_t state_ = SIMIX_WAITING; /* State of the activity */
   std::list<smx_simcall_t> simcalls_;   /* List of simcalls waiting for this activity */
   resource::Action* surf_action_ = nullptr;
index 4b66dd2..bffe2f5 100644 (file)
@@ -61,8 +61,6 @@ ExecImpl::ExecImpl(const std::string& name, const std::string& tracing_category)
 
 ExecImpl::~ExecImpl()
 {
 
 ExecImpl::~ExecImpl()
 {
-  if (surf_action_)
-    surf_action_->unref();
   if (timeout_detector_)
     timeout_detector_->unref();
   XBT_DEBUG("Destroy exec %p", this);
   if (timeout_detector_)
     timeout_detector_->unref();
   XBT_DEBUG("Destroy exec %p", this);
index 74daa44..e784634 100644 (file)
@@ -16,7 +16,7 @@ namespace activity {
 
 class XBT_PUBLIC ExecImpl : public ActivityImpl {
   resource::Action* timeout_detector_ = nullptr;
 
 class XBT_PUBLIC ExecImpl : public ActivityImpl {
   resource::Action* timeout_detector_ = nullptr;
-  ~ExecImpl() override;
+  ~ExecImpl();
 
 public:
   explicit ExecImpl(const std::string& name, const std::string& tracing_category);
 
 public:
   explicit ExecImpl(const std::string& name, const std::string& tracing_category);
index 822ff10..1a08cb3 100644 (file)
@@ -37,13 +37,6 @@ namespace simgrid {
 namespace kernel {
 namespace activity {
 
 namespace kernel {
 namespace activity {
 
-IoImpl::~IoImpl()
-{
-  if (surf_action_ != nullptr)
-    surf_action_->unref();
-  XBT_DEBUG("Destroy io %p", this);
-}
-
 IoImplPtr IoImpl::set_name(const std::string& name)
 {
   ActivityImpl::set_name(name);
 IoImplPtr IoImpl::set_name(const std::string& name)
 {
   ActivityImpl::set_name(name);
index 5e50b88..e71a11e 100644 (file)
@@ -21,9 +21,6 @@ class XBT_PUBLIC IoImpl : public ActivityImpl {
   sg_size_t performed_ioops_      = 0;
 
 public:
   sg_size_t performed_ioops_      = 0;
 
 public:
-  ~IoImpl() override;
-  IoImpl() = default;
-
   IoImplPtr set_name(const std::string& name);
   IoImplPtr set_size(sg_size_t size);
   IoImplPtr set_type(s4u::Io::OpType type);
   IoImplPtr set_name(const std::string& name);
   IoImplPtr set_size(sg_size_t size);
   IoImplPtr set_type(s4u::Io::OpType type);
index 8735baf..addab36 100644 (file)
@@ -18,13 +18,6 @@ namespace simgrid {
 namespace kernel {
 namespace activity {
 
 namespace kernel {
 namespace activity {
 
-SleepImpl::~SleepImpl()
-{
-  if (surf_action_)
-    surf_action_->unref();
-  XBT_DEBUG("Destroy activity %p", this);
-}
-
 SleepImpl* SleepImpl::start(double duration)
 {
   surf_action_ = host_->pimpl_cpu->sleep(duration);
 SleepImpl* SleepImpl::start(double duration)
 {
   surf_action_ = host_->pimpl_cpu->sleep(duration);
index 2bf4657..d4f83e0 100644 (file)
@@ -14,8 +14,6 @@ namespace kernel {
 namespace activity {
 
 class XBT_PUBLIC SleepImpl : public ActivityImpl {
 namespace activity {
 
 class XBT_PUBLIC SleepImpl : public ActivityImpl {
-  ~SleepImpl() override;
-
 public:
   explicit SleepImpl(const std::string& name, s4u::Host* host) : ActivityImpl(name), host_(host) {}
   void post() override;
 public:
   explicit SleepImpl(const std::string& name, s4u::Host* host) : ActivityImpl(name), host_(host) {}
   void post() override;
index d58e1e4..d736bbf 100644 (file)
@@ -27,11 +27,6 @@ RawImpl* RawImpl::start(s4u::Host* host, double timeout)
   return this;
 }
 
   return this;
 }
 
-RawImpl::~RawImpl()
-{
-  surf_action_->unref();
-}
-
 void RawImpl::suspend()
 {
   /* The suspension of raw synchros is delayed to when the process is rescheduled. */
 void RawImpl::suspend()
 {
   /* The suspension of raw synchros is delayed to when the process is rescheduled. */
index da5766b..9ed5cf9 100644 (file)
@@ -16,7 +16,6 @@ namespace activity {
   /** Used to implement mutexes, semaphores and conditions */
 class XBT_PUBLIC RawImpl : public ActivityImpl {
 public:
   /** Used to implement mutexes, semaphores and conditions */
 class XBT_PUBLIC RawImpl : public ActivityImpl {
 public:
-  ~RawImpl() override;
   RawImpl* start(s4u::Host* host, double timeout);
   void suspend() override;
   void resume() override;
   RawImpl* start(s4u::Host* host, double timeout);
   void suspend() override;
   void resume() override;