X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/0a627c31b59202d8f087c64ec40cc14fc0d3a5c4..594b10a112b66208df1de4b26d65d93d601a128e:/src/s4u/s4u_Comm.cpp diff --git a/src/s4u/s4u_Comm.cpp b/src/s4u/s4u_Comm.cpp index 50eaf00d28..c770e2ca8d 100644 --- a/src/s4u/s4u_Comm.cpp +++ b/src/s4u/s4u_Comm.cpp @@ -6,6 +6,7 @@ #include "src/msg/msg_private.hpp" #include "xbt/log.h" +#include "simgrid/Exception.hpp" #include "simgrid/s4u/Comm.hpp" #include "simgrid/s4u/Mailbox.hpp" @@ -167,6 +168,9 @@ Comm* Comm::wait_for(double timeout) state_ = State::FINISHED; return this; + case State::CANCELED: + throw CancelException(XBT_THROW_POINT, "Communication canceled"); + default: THROW_IMPOSSIBLE; } @@ -193,7 +197,10 @@ Comm* Comm::detach() Comm* Comm::cancel() { - simgrid::simix::simcall([this] { static_cast(pimpl_.get())->cancel(); }); + simgrid::simix::simcall([this] { + if (pimpl_) + boost::static_pointer_cast(pimpl_)->cancel(); + }); state_ = State::CANCELED; return this; }