Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
New function s4u::Mutex::get_owner()
authorMartin Quinson <martin.quinson@ens-rennes.fr>
Sun, 12 Nov 2023 22:30:43 +0000 (23:30 +0100)
committerMartin Quinson <martin.quinson@ens-rennes.fr>
Mon, 13 Nov 2023 15:05:52 +0000 (16:05 +0100)
ChangeLog
include/simgrid/s4u/Mutex.hpp
src/s4u/s4u_Mutex.cpp

index 66d4a37..c8084ce 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -20,6 +20,7 @@ S4U:
    The behavior of a MessageQueue is similar to that of a Mailbox, but intended for
    control messages that do not incur any simulated cost. Information is automagically
    transported over thin air between producer and consumer. See examples/cpp/mess-wait
+ - New function: Mutex::get_owner()
 
 New S4U plugins:
  - Add a JBOD (just a bunch of disks) concept. It's a sort of host with many disks.
index 06f04c2..29d9ed1 100644 (file)
@@ -6,6 +6,7 @@
 #ifndef SIMGRID_S4U_MUTEX_HPP
 #define SIMGRID_S4U_MUTEX_HPP
 
+#include "simgrid/s4u/Actor.hpp"
 #include <simgrid/forward.h>
 #include <xbt/asserts.h>
 
@@ -55,6 +56,8 @@ public:
   void lock();
   void unlock();
   bool try_lock();
+
+  Actor* get_owner();
 };
 
 } // namespace simgrid::s4u
index 12fa915..e2cc10d 100644 (file)
@@ -61,6 +61,14 @@ MutexPtr Mutex::create(bool recursive)
   return MutexPtr(&mutex->mutex(), false);
 }
 
+Actor* Mutex::get_owner()
+{
+  auto* owner = pimpl_->get_owner();
+  if (owner == nullptr)
+    return nullptr;
+  return owner->get_ciface();
+}
+
 /* refcounting of the intrusive_ptr is delegated to the implementation object */
 void intrusive_ptr_add_ref(const Mutex* mutex)
 {