- /* If we reached this point, the wait simcall must have a timeout */
- /* Otherwise it shouldn't be enabled and executed by the MC */
- if (timeout < 0.0)
- THROW_IMPOSSIBLE;
- state_ = simgrid::kernel::activity::State::TIMEOUT;
+ SynchroImplPtr synchro(new SynchroImpl([this, issuer]() {
+ this->unregister_simcall(&issuer->simcall_);
+ issuer->waiting_synchro_ = nullptr;
+ issuer->exception_ = nullptr;
+ auto* observer = dynamic_cast<kernel::actor::ActivityWaitSimcall*>(issuer->simcall_.observer_);
+ xbt_assert(observer != nullptr);
+ observer->set_result(true); // Returns that the wait_for timeouted
+ }));
+ synchro->set_host(issuer->get_host()).set_timeout(timeout).start();
+ synchro->register_simcall(&issuer->simcall_);
+ }
+ }
+}
+
+void ActivityImpl::wait_any_for(actor::ActorImpl* issuer, const std::vector<ActivityImpl*>& activities, double timeout)
+{
+ XBT_DEBUG("Wait for execution of any synchro");
+ if (MC_is_active() || MC_record_replay_is_active()) {
+ auto* observer = dynamic_cast<kernel::actor::ActivityWaitanySimcall*>(issuer->simcall_.observer_);
+ xbt_assert(observer != nullptr);
+ xbt_assert(timeout <= 0.0, "Timeout not implemented for waitany in the model-checker");
+ if (int idx = observer->get_value(); idx != -1) {
+ auto* act = activities.at(idx);
+ act->simcalls_.push_back(&issuer->simcall_);
+ observer->set_result(idx);
+ act->set_state(State::DONE);
+ act->finish();