X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/52ce12f030da64a5c1e6eb3a644b75276c5194e7..7579d38e6a52dc50d2fe8d7f61eaa989c26ea6b6:/src/kernel/activity/IoImpl.cpp diff --git a/src/kernel/activity/IoImpl.cpp b/src/kernel/activity/IoImpl.cpp index 5daae909fa..c9f8e3553a 100644 --- a/src/kernel/activity/IoImpl.cpp +++ b/src/kernel/activity/IoImpl.cpp @@ -108,6 +108,25 @@ void IoImpl::post() /* Answer all simcalls associated with the synchro */ finish(); } +void IoImpl::set_exception(actor::ActorImpl* issuer) +{ + switch (state_) { + case State::FAILED: + issuer->context_->set_wannadie(); + piface_->complete(s4u::Activity::State::FAILED); + issuer->exception_ = std::make_exception_ptr(StorageFailureException(XBT_THROW_POINT, "Storage failed")); + break; + case State::CANCELED: + issuer->exception_ = std::make_exception_ptr(CancelException(XBT_THROW_POINT, "I/O Canceled")); + break; + case State::TIMEOUT: + issuer->exception_ = std::make_exception_ptr(TimeoutException(XBT_THROW_POINT, "Timeouted")); + break; + default: + xbt_assert(state_ == State::DONE, "Internal error in IoImpl::finish(): unexpected synchro state %s", + to_c_str(state_)); + } +} void IoImpl::finish() { @@ -141,23 +160,7 @@ void IoImpl::finish() } } - switch (state_) { - case State::FAILED: - simcall->issuer_->context_->set_wannadie(); - piface_->complete(s4u::Activity::State::FAILED); - simcall->issuer_->exception_ = - std::make_exception_ptr(StorageFailureException(XBT_THROW_POINT, "Storage failed")); - break; - case State::CANCELED: - simcall->issuer_->exception_ = std::make_exception_ptr(CancelException(XBT_THROW_POINT, "I/O Canceled")); - break; - case State::TIMEOUT: - simcall->issuer_->exception_ = std::make_exception_ptr(TimeoutException(XBT_THROW_POINT, "Timeouted")); - break; - default: - xbt_assert(state_ == State::DONE, "Internal error in IoImpl::finish(): unexpected synchro state %s", - to_c_str(state_)); - } + set_exception(simcall->issuer_); simcall->issuer_->waiting_synchro_ = nullptr; simcall->issuer_->simcall_answer();