Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Update copyright lines for 2023.
[simgrid.git] / src / kernel / activity / MutexImpl.hpp
index bbdef1c..c7ba205 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2022. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2012-2023. 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. */
@@ -11,9 +11,7 @@
 #include "src/kernel/actor/ActorImpl.hpp"
 #include <boost/intrusive/list.hpp>
 
-namespace simgrid {
-namespace kernel {
-namespace activity {
+namespace simgrid::kernel::activity {
 
 /** Mutex Acquisition: the act / process of acquiring the mutex.
  *
@@ -41,8 +39,7 @@ namespace activity {
  * of a set if some transitions may become disabled in between, while you don't have to reconsider them if you can reuse
  * your previous computations).
  */
-class XBT_PUBLIC MutexAcquisitionImpl
-    : public ActivityImpl_T<MutexAcquisitionImpl> { // Acquisition: n. The act or process of acquiring.
+class XBT_PUBLIC MutexAcquisitionImpl : public ActivityImpl_T<MutexAcquisitionImpl> {
   actor::ActorImpl* issuer_ = nullptr;
   MutexImpl* mutex_         = nullptr;
 
@@ -66,8 +63,9 @@ class XBT_PUBLIC MutexImpl {
   std::atomic_int_fast32_t refcount_{1};
   s4u::Mutex piface_;
   actor::ActorImpl* owner_ = nullptr;
-  // List of sleeping actors:
-  std::deque<MutexAcquisitionImplPtr> sleeping_;
+  std::deque<MutexAcquisitionImplPtr> ongoing_acquisitions_;
+  static unsigned next_id_;
+  unsigned id_ = next_id_++;
 
   friend MutexAcquisitionImpl;
 
@@ -79,9 +77,7 @@ public:
   MutexAcquisitionImplPtr lock_async(actor::ActorImpl* issuer);
   bool try_lock(actor::ActorImpl* issuer);
   void unlock(actor::ActorImpl* issuer);
-
-  MutexImpl* ref();
-  void unref();
+  unsigned get_id() const { return id_; }
 
   actor::ActorImpl* get_owner() const { return owner_; }
 
@@ -100,7 +96,5 @@ public:
 
   s4u::Mutex& mutex() { return piface_; }
 };
-} // namespace activity
-} // namespace kernel
-} // namespace simgrid
+} // namespace simgrid::kernel::activity
 #endif