Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
stick to our coding standards: fields must have a trailing _
[simgrid.git] / src / kernel / activity / SemaphoreImpl.cpp
index 4848f27..bf3407e 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2019-2020. 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. */
@@ -14,14 +14,11 @@ namespace activity {
 
 void SemaphoreImpl::acquire(actor::ActorImpl* issuer, double timeout)
 {
-  RawImplPtr synchro = nullptr;
-
   XBT_DEBUG("Wait semaphore %p (timeout:%f)", this, timeout);
   if (value_ <= 0) {
-    synchro = RawImplPtr(new RawImpl());
-    (*synchro).set_host(issuer->get_host()).set_timeout(timeout).start();
-    synchro->simcalls_.push_front(&issuer->simcall);
-    issuer->waiting_synchro = synchro;
+    RawImplPtr synchro = RawImplPtr(new RawImpl());
+    synchro->set_host(issuer->get_host()).set_timeout(timeout).start();
+    synchro->register_simcall(&issuer->simcall_);
     sleeping_.push_back(*issuer);
   } else {
     value_--;
@@ -35,7 +32,7 @@ void SemaphoreImpl::release()
   if (not sleeping_.empty()) {
     auto& actor = sleeping_.front();
     sleeping_.pop_front();
-    actor.waiting_synchro = nullptr;
+    actor.waiting_synchro_ = nullptr;
     actor.simcall_answer();
   } else {
     value_++;