-/*************
- * Callbacks *
- *************/
-simgrid::xbt::signal<void(simgrid::kernel::activity::IoImplPtr)> simgrid::kernel::activity::IoImpl::on_start;
-simgrid::xbt::signal<void(simgrid::kernel::activity::IoImplPtr)> simgrid::kernel::activity::IoImpl::on_completion;
+
+void IoImpl::finish()
+{
+ XBT_DEBUG("IoImpl::finish() in state %s", to_c_str(state_));
+ while (not simcalls_.empty()) {
+ const s_smx_simcall* simcall = simcalls_.front();
+ simcalls_.pop_front();
+ switch (state_) {
+ case State::FAILED:
+ simcall->issuer_->context_->set_wannadie();
+ 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(simgrid::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_));
+ }
+
+ simcall->issuer_->waiting_synchro_ = nullptr;
+ simcall->issuer_->simcall_answer();
+ }
+}
+
+} // namespace activity
+} // namespace kernel
+} // namespace simgrid