Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Cosmetics around #include.
[simgrid.git] / src / kernel / activity / SemaphoreImpl.cpp
index fd9877f..98d38be 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2019-2020. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2019-2021. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -16,7 +16,11 @@ void SemaphoreImpl::acquire(actor::ActorImpl* issuer, double timeout)
 {
   XBT_DEBUG("Wait semaphore %p (timeout:%f)", this, timeout);
   if (value_ <= 0) {
-    RawImplPtr synchro(new RawImpl());
+    RawImplPtr synchro(new RawImpl([this, issuer]() {
+      this->remove_sleeping_actor(*issuer);
+      if (issuer->simcall_.call_ == simix::Simcall::SEM_ACQUIRE_TIMEOUT)
+        simcall_sem_acquire_timeout__set__result(&issuer->simcall_, 1);
+    }));
     synchro->set_host(issuer->get_host()).set_timeout(timeout).start();
     synchro->register_simcall(&issuer->simcall_);
     sleeping_.push_back(*issuer);