Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
factor cancel across activities
[simgrid.git] / src / kernel / activity / IoImpl.cpp
index 822ff10cea994be622c34dcd03409bc220125d1f..a35e92672a1afe08de15abb68e90f423fc3de1c8 100644 (file)
@@ -37,35 +37,22 @@ namespace simgrid {
 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);
-  return this;
-}
-
-IoImplPtr IoImpl::set_type(s4u::Io::OpType type)
+IoImpl& IoImpl::set_type(s4u::Io::OpType type)
 {
   type_ = type;
-  return this;
+  return *this;
 }
 
-IoImplPtr IoImpl::set_size(sg_size_t size)
+IoImpl& IoImpl::set_size(sg_size_t size)
 {
   size_ = size;
-  return this;
+  return *this;
 }
 
-IoImplPtr IoImpl::set_storage(resource::StorageImpl* storage)
+IoImpl& IoImpl::set_storage(resource::StorageImpl* storage)
 {
   storage_ = storage;
-  return this;
+  return *this;
 }
 
 IoImpl* IoImpl::start()
@@ -75,24 +62,11 @@ IoImpl* IoImpl::start()
   surf_action_->set_data(this);
 
   XBT_DEBUG("Create IO synchro %p %s", this, get_cname());
-  IoImpl::on_start(this);
+  IoImpl::on_start(*this);
 
   return this;
 }
 
-void IoImpl::cancel()
-{
-  XBT_VERB("This exec %p is canceled", this);
-  if (surf_action_ != nullptr)
-    surf_action_->cancel();
-  state_ = SIMIX_CANCELED;
-}
-
-double IoImpl::get_remaining()
-{
-  return surf_action_ ? surf_action_->get_remains() : 0;
-}
-
 void IoImpl::post()
 {
   performed_ioops_ = surf_action_->get_cost();
@@ -106,7 +80,7 @@ void IoImpl::post()
     default:
       THROW_IMPOSSIBLE;
   }
-  on_completion(this);
+  on_completion(*this);
 
   finish();
 }
@@ -141,8 +115,8 @@ void IoImpl::finish()
 /*************
  * Callbacks *
  *************/
-xbt::signal<void(IoImplPtr)> IoImpl::on_start;
-xbt::signal<void(IoImplPtr)> IoImpl::on_completion;
+xbt::signal<void(IoImpl const&)> IoImpl::on_start;
+xbt::signal<void(IoImpl const&)> IoImpl::on_completion;
 
 } // namespace activity
 } // namespace kernel