X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/370d85c0bc1fd13c8444a243ecd4390012f5c246..1b94b2100679d5b4355fccb6d22927efc12ca5bc:/src/s4u/s4u_Comm.cpp diff --git a/src/s4u/s4u_Comm.cpp b/src/s4u/s4u_Comm.cpp index 7eb4685229..a841ac44ac 100644 --- a/src/s4u/s4u_Comm.cpp +++ b/src/s4u/s4u_Comm.cpp @@ -4,8 +4,10 @@ * under the terms of the license (GNU LGPL) which comes with this package. */ #include "src/msg/msg_private.hpp" +#include "src/simix/ActorImpl.hpp" #include "xbt/log.h" +#include "simgrid/Exception.hpp" #include "simgrid/s4u/Comm.hpp" #include "simgrid/s4u/Mailbox.hpp" @@ -145,7 +147,7 @@ Comm* Comm::wait_for(double timeout) { 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) { @@ -159,16 +161,17 @@ Comm* Comm::wait_for(double timeout) 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: - return this; + throw CancelException(XBT_THROW_POINT, "Communication canceled"); + default: THROW_IMPOSSIBLE; } @@ -225,6 +228,11 @@ MailboxPtr Comm::get_mailbox() return mailbox_; } +ActorPtr Comm::get_sender() +{ + return sender_ ? sender_->iface() : nullptr; +} + void intrusive_ptr_release(simgrid::s4u::Comm* c) { if (c->refcount_.fetch_sub(1, std::memory_order_release) == 1) {