Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
cosmetics (codefactor+coding style)
[simgrid.git] / src / kernel / activity / MutexImpl.hpp
index b60f735..f372ea7 100644 (file)
@@ -3,8 +3,8 @@
 /* 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. */
 
-#ifndef SIMIX_MUTEXIMPL_HPP
-#define SIMIX_MUTEXIMPL_HPP
+#ifndef SIMGRID_KERNEL_ACTIVITY_MUTEX_HPP
+#define SIMGRID_KERNEL_ACTIVITY_MUTEX_HPP
 
 #include "simgrid/s4u/ConditionVariable.hpp"
 #include "src/kernel/actor/ActorImpl.hpp"
@@ -15,19 +15,23 @@ namespace kernel {
 namespace activity {
 
 class XBT_PUBLIC MutexImpl {
+  std::atomic_int_fast32_t refcount_{1};
+  s4u::Mutex piface_;
+  bool locked_ = false;
+
 public:
-  MutexImpl();
-  ~MutexImpl();
+  MutexImpl() : piface_(this) {}
   MutexImpl(MutexImpl const&) = delete;
   MutexImpl& operator=(MutexImpl const&) = delete;
 
   void lock(actor::ActorImpl* issuer);
   bool try_lock(actor::ActorImpl* issuer);
   void unlock(actor::ActorImpl* issuer);
+  bool is_locked() { return locked_; }
 
   MutexImpl* ref();
   void unref();
-  bool locked_             = false;
+
   actor::ActorImpl* owner_ = nullptr;
   // List of sleeping actors:
   actor::SynchroList sleeping_;
@@ -46,12 +50,8 @@ public:
   }
 
   s4u::Mutex& mutex() { return piface_; }
-
-private:
-  std::atomic_int_fast32_t refcount_{1};
-  s4u::Mutex piface_;
 };
-}
-}
-}
-#endif /* SIMIX_MUTEXIMPL_HPP */
+} // namespace activity
+} // namespace kernel
+} // namespace simgrid
+#endif