Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
fix some issues with Cancel
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Thu, 21 Feb 2019 19:29:21 +0000 (20:29 +0100)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Thu, 21 Feb 2019 19:29:21 +0000 (20:29 +0100)
* Comm::cancel can be called when there is no pimpl
* if we wait for a canceled activity we can return not let the
impossible happen.

src/s4u/s4u_Comm.cpp

index 50eaf00..7eb4685 100644 (file)
@@ -167,6 +167,8 @@ Comm* Comm::wait_for(double timeout)
       state_ = State::FINISHED;
       return this;
 
       state_ = State::FINISHED;
       return this;
 
+    case State::CANCELED:
+      return this;
     default:
       THROW_IMPOSSIBLE;
   }
     default:
       THROW_IMPOSSIBLE;
   }
@@ -193,7 +195,10 @@ Comm* Comm::detach()
 
 Comm* Comm::cancel()
 {
 
 Comm* Comm::cancel()
 {
-  simgrid::simix::simcall([this] { static_cast<kernel::activity::CommImpl*>(pimpl_.get())->cancel(); });
+  simgrid::simix::simcall([this] {
+    if (pimpl_)
+      boost::static_pointer_cast<kernel::activity::CommImpl>(pimpl_)->cancel();
+  });
   state_ = State::CANCELED;
   return this;
 }
   state_ = State::CANCELED;
   return this;
 }