- for (smx_simcall_t const& simcall : simcalls_) {
- switch (simcall->call) {
- case SIMCALL_STORAGE_WRITE:
- simcall_storage_write__set__result(simcall, surf_action_->get_cost());
+ disk_ = disk;
+ return *this;
+}
+
+IoImpl& IoImpl::set_storage(resource::StorageImpl* storage)
+{
+ storage_ = storage;
+ return *this;
+}
+
+IoImpl* IoImpl::start()
+{
+ state_ = SIMIX_RUNNING;
+ if (storage_)
+ surf_action_ = storage_->io_start(size_, type_);
+ else
+ surf_action_ = disk_->io_start(size_, type_);
+ surf_action_->set_activity(this);
+
+ XBT_DEBUG("Create IO synchro %p %s", this, get_cname());
+ IoImpl::on_start(*this);
+
+ return this;
+}
+
+void IoImpl::post()
+{
+ performed_ioops_ = surf_action_->get_cost();
+ if (surf_action_->get_state() == resource::Action::State::FAILED) {
+ if ((storage_ && not storage_->is_on()) || (disk_ && not disk_->is_on()))
+ state_ = SIMIX_FAILED;
+ else
+ state_ = SIMIX_CANCELED;
+ } else if (surf_action_->get_state() == resource::Action::State::FINISHED) {
+ state_ = SIMIX_DONE;
+ }
+ on_completion(*this);
+
+ /* Answer all simcalls associated with the synchro */
+ finish();
+}
+
+void IoImpl::finish()
+{
+ while (not simcalls_.empty()) {
+ smx_simcall_t simcall = simcalls_.front();
+ simcalls_.pop_front();
+ switch (state_) {
+ case SIMIX_DONE:
+ /* do nothing, synchro done */