Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Cosmetics around #include.
[simgrid.git] / src / kernel / activity / ConditionVariableImpl.cpp
index 6193dfd3ef57dabebb3824f9fe3abc6d84437773..12ef6d002925329d119e70b251b7371ebe431fa0 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-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. */
@@ -55,7 +55,7 @@ void ConditionVariableImpl::signal()
       simcall_mutex = simcall_cond_wait__get__mutex(simcall);
     else
       simcall_mutex = simcall_cond_wait_timeout__get__mutex(simcall);
-    simcall->call_ = simix::Simcall::MUTEX_LOCK;
+    simcall->call_ = simix::Simcall::RUN_BLOCKING;
 
     simcall_mutex->lock(simcall->issuer_);
   }
@@ -90,7 +90,11 @@ void ConditionVariableImpl::wait(smx_mutex_t mutex, double timeout, actor::Actor
     mutex->unlock(issuer);
   }
 
-  RawImplPtr synchro(new RawImpl());
+  RawImplPtr synchro(new RawImpl([this, issuer]() {
+    this->remove_sleeping_actor(*issuer);
+    if (issuer->simcall_.call_ == simix::Simcall::COND_WAIT_TIMEOUT)
+      simcall_cond_wait_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);