- if (not sleeping_.empty()) {
- auto& actor = sleeping_.front();
- sleeping_.pop_front();
- actor.waiting_synchro = nullptr;
- actor.simcall_answer();
- } else {
- value_++;
+ if (model_action_ != nullptr) { // A timeout was declared
+ if (model_action_->get_state() == resource::Action::State::FINISHED) { // The timeout elapsed
+ if (granted_) { // but we got the semaphore, just in time!
+ set_state(State::DONE);
+
+ } else { // we have to report that timeout
+ cancel(); // Unregister the acquisition from the semaphore
+
+ /* Return to the englobing simcall that the wait_for timeouted */
+ auto* observer = dynamic_cast<kernel::actor::SemaphoreAcquisitionObserver*>(get_issuer()->simcall_.observer_);
+ xbt_assert(observer != nullptr);
+ observer->set_result(true);
+ }
+ }
+ model_action_->unref();
+ model_action_ = nullptr;