#include "src/msg/msg_private.hpp"
#include "xbt/log.h"
+#include "simgrid/Exception.hpp"
#include "simgrid/s4u/Comm.hpp"
#include "simgrid/s4u/Mailbox.hpp"
{
switch (state_) {
case State::FINISHED:
- return this;
+ break;
case State::INITED: // It's not started yet. Do it in one simcall
if (src_buff_ != nullptr) {
user_data_, timeout, rate_);
}
state_ = State::FINISHED;
- return this;
+ break;
case State::STARTED:
simcall_comm_wait(pimpl_, timeout);
on_completion(Actor::self());
state_ = State::FINISHED;
- return this;
+ break;
+
+ case State::CANCELED:
+ throw CancelException(XBT_THROW_POINT, "Communication canceled");
default:
THROW_IMPOSSIBLE;
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;
}