]> AND Public Git Repository - simgrid.git/blobdiff - src/kernel/activity/SemaphoreImpl.hpp
Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Variable is declared in xbt/asserts.h.
[simgrid.git] / src / kernel / activity / SemaphoreImpl.hpp
index 460fc514b745c45b5161c80609b41151f356efef..d715a650a5ff35e3f2ba912d7cc9e4eff30a5813 100644 (file)
 
 #include "simgrid/s4u/Semaphore.hpp"
 #include "src/kernel/actor/ActorImpl.hpp"
+#include "src/kernel/actor/SynchroObserver.hpp"
 
-namespace simgrid {
-namespace kernel {
-namespace activity {
+namespace simgrid::kernel::activity {
 
 /** Semaphore Acquisition: the act / process of acquiring the semaphore.
  *
@@ -27,6 +26,7 @@ class XBT_PUBLIC SemAcquisitionImpl : public ActivityImpl_T<SemAcquisitionImpl>
   bool granted_             = false;
 
   friend SemaphoreImpl;
+  friend actor::SemaphoreAcquisitionObserver;
 
 public:
   SemAcquisitionImpl(actor::ActorImpl* issuer, SemaphoreImpl* sem) : issuer_(issuer), semaphore_(sem) {}
@@ -49,7 +49,11 @@ class XBT_PUBLIC SemaphoreImpl {
   unsigned int value_;
   std::deque<SemAcquisitionImplPtr> ongoing_acquisitions_;
 
+  static unsigned next_id_;
+  unsigned id_ = next_id_++;
+
   friend SemAcquisitionImpl;
+  friend actor::SemaphoreObserver;
 
 public:
   explicit SemaphoreImpl(unsigned int value) : piface_(this), value_(value){};
@@ -76,11 +80,9 @@ public:
       delete sem;
     }
   }
-
+  unsigned get_id() const { return id_; }
   s4u::Semaphore& sem() { return piface_; }
 };
-} // namespace activity
-} // namespace kernel
-} // namespace simgrid
+} // namespace simgrid::kernel::activity
 
 #endif /* SIMGRID_KERNEL_ACTIVITY_SEMAPHOREIMPL_HPP */