bool ActivityImpl::test(actor::ActorImpl* issuer)
{
if (state_ != State::WAITING && state_ != State::RUNNING) {
- finish();
+ post();
issuer->exception_ = nullptr; // Do not propagate exception in that case
return true;
}
/* If the synchro is already finished then perform the error handling */
if (state_ != State::WAITING && state_ != State::RUNNING) {
- finish();
+ post();
} else {
/* we need a sleep action (even when the timeout is infinite) to be notified of host failures */
/* Comms handle that a bit differently of the other activities */
act->simcalls_.push_back(&issuer->simcall_);
observer->set_result(idx);
act->set_state(State::DONE);
- act->finish();
+ act->post();
}
return;
}
act->simcalls_.push_back(&issuer->simcall_);
/* see if the synchro is already finished */
if (act->get_state() != State::WAITING && act->get_state() != State::RUNNING) {
- act->finish();
+ act->post();
break;
}
}
void ExecImpl::post()
{
- xbt_assert(model_action_ != nullptr);
- if (auto const& hosts = get_hosts();
- std::any_of(hosts.begin(), hosts.end(), [](const s4u::Host* host) { return not host->is_on(); })) {
- /* If one of the hosts running the synchro failed, notice it. This way, the asking
- * process can be killed if it runs on that host itself */
- set_state(State::FAILED);
- } else if (model_action_->get_state() == resource::Action::State::FAILED) {
- /* If all the hosts are running the synchro didn't fail, then the synchro was canceled */
- set_state(State::CANCELED);
- } else {
- set_state(State::DONE);
+ if (model_action_ != nullptr) {
+ if (auto const& hosts = get_hosts();
+ std::any_of(hosts.begin(), hosts.end(), [](const s4u::Host* host) { return not host->is_on(); })) {
+ /* If one of the hosts running the synchro failed, notice it. This way, the asking
+ * process can be killed if it runs on that host itself */
+ set_state(State::FAILED);
+ } else if (model_action_->get_state() == resource::Action::State::FAILED) {
+ /* If all the hosts are running the synchro didn't fail, then the synchro was canceled */
+ set_state(State::CANCELED);
+ } else {
+ set_state(State::DONE);
+ }
+
+ clean_action();
}
- clean_action();
- if (get_actor() != nullptr) {
+ if (get_actor() != nullptr)
get_actor()->activities_.erase(this);
- }
+
if (get_state() != State::FAILED && cb_id_ >= 0)
s4u::Host::on_state_change.disconnect(cb_id_);
/* Answer all simcalls associated with the synchro */
void IoImpl::post()
{
- performed_ioops_ = model_action_->get_cost();
- if (model_action_->get_state() == resource::Action::State::FAILED) {
- if (host_ && dst_host_) { // this is an I/O stream
- if (not host_->is_on())
- set_state(State::SRC_HOST_FAILURE);
- else if (not dst_host_->is_on())
- set_state(State::DST_HOST_FAILURE);
- } else if ((disk_ && not disk_->is_on()) || (dst_disk_ && not dst_disk_->is_on()))
- set_state(State::FAILED);
- else
- set_state(State::CANCELED);
- } else {
- set_state(State::DONE);
- }
+ if (model_action_ != nullptr) {
+ performed_ioops_ = model_action_->get_cost();
+ if (model_action_->get_state() == resource::Action::State::FAILED) {
+ if (host_ && dst_host_) { // this is an I/O stream
+ if (not host_->is_on())
+ set_state(State::SRC_HOST_FAILURE);
+ else if (not dst_host_->is_on())
+ set_state(State::DST_HOST_FAILURE);
+ } else if ((disk_ && not disk_->is_on()) || (dst_disk_ && not dst_disk_->is_on()))
+ set_state(State::FAILED);
+ else
+ set_state(State::CANCELED);
+ } else {
+ set_state(State::DONE);
+ }
- clean_action();
+ clean_action();
+ }
/* Answer all simcalls associated with the synchro */
finish();