+void ActivityImpl::handle_activity_waitany(actor::Simcall* simcall)
+{
+ /* If a waitany simcall is waiting for this synchro to finish, then remove it from the other synchros in the waitany
+ * list. Afterwards, get the position of the actual synchro in the waitany list and return it as the result of the
+ * simcall */
+ if (auto* observer = dynamic_cast<actor::ActivityWaitanySimcall*>(simcall->observer_)) {
+ if (simcall->timeout_cb_) {
+ simcall->timeout_cb_->remove();
+ simcall->timeout_cb_ = nullptr;
+ }
+
+ auto activities = observer->get_activities();
+ for (auto* act : activities)
+ act->unregister_simcall(simcall);
+
+ if (not MC_is_active() && not MC_record_replay_is_active()) {
+ auto element = std::find(activities.begin(), activities.end(), this);
+ int rank = element != activities.end() ? static_cast<int>(std::distance(activities.begin(), element)) : -1;
+ observer->set_result(rank);
+ }
+ }
+}
+