From: Martin Quinson Date: Sun, 12 Nov 2023 22:30:43 +0000 (+0100) Subject: New function s4u::Mutex::get_owner() X-Git-Tag: v3.35~66 X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/4fb5244980199691e9976323c2c3a09ebb168242 New function s4u::Mutex::get_owner() --- diff --git a/ChangeLog b/ChangeLog index 66d4a379a9..c8084cea5d 100644 --- 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. diff --git a/include/simgrid/s4u/Mutex.hpp b/include/simgrid/s4u/Mutex.hpp index 06f04c2aa5..29d9ed1043 100644 --- a/include/simgrid/s4u/Mutex.hpp +++ b/include/simgrid/s4u/Mutex.hpp @@ -6,6 +6,7 @@ #ifndef SIMGRID_S4U_MUTEX_HPP #define SIMGRID_S4U_MUTEX_HPP +#include "simgrid/s4u/Actor.hpp" #include #include @@ -55,6 +56,8 @@ public: void lock(); void unlock(); bool try_lock(); + + Actor* get_owner(); }; } // namespace simgrid::s4u diff --git a/src/s4u/s4u_Mutex.cpp b/src/s4u/s4u_Mutex.cpp index 12fa915d5b..e2cc10d007 100644 --- a/src/s4u/s4u_Mutex.cpp +++ b/src/s4u/s4u_Mutex.cpp @@ -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) {