From: Martin Quinson Date: Sat, 19 Mar 2022 19:12:48 +0000 (+0100) Subject: Give users a way to debug their barriers X-Git-Tag: v3.31~31 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/c3aba869402fd6e57bd6c70dde801e6995037d99 Give users a way to debug their barriers --- diff --git a/include/simgrid/s4u/Barrier.hpp b/include/simgrid/s4u/Barrier.hpp index 1e5e589f75..547f5d82d4 100644 --- a/include/simgrid/s4u/Barrier.hpp +++ b/include/simgrid/s4u/Barrier.hpp @@ -34,6 +34,8 @@ public: static BarrierPtr create(unsigned int expected_actors); /** Blocks into the barrier. Every waiting actors will be unlocked once the expected amount of actors reaches the barrier */ int wait(); + /** Returns some debug information about the barrier */ + std::string to_string(); #ifndef DOXYGEN /* refcounting */ diff --git a/src/kernel/activity/BarrierImpl.hpp b/src/kernel/activity/BarrierImpl.hpp index e34ba73ac6..b214e5f161 100644 --- a/src/kernel/activity/BarrierImpl.hpp +++ b/src/kernel/activity/BarrierImpl.hpp @@ -74,6 +74,11 @@ public: } s4u::Barrier& get_iface() { return piface_; } + + std::string to_string() + { + return xbt::string_printf("Barrier %d: %zu of %u", id_, ongoing_acquisitions_.size(), expected_actors_); + } }; } // namespace activity } // namespace kernel diff --git a/src/s4u/s4u_Barrier.cpp b/src/s4u/s4u_Barrier.cpp index 8aa46d2392..297109e115 100644 --- a/src/s4u/s4u_Barrier.cpp +++ b/src/s4u/s4u_Barrier.cpp @@ -53,6 +53,11 @@ int Barrier::wait() } } +std::string Barrier::to_string() +{ + return pimpl_->to_string(); +} + void intrusive_ptr_add_ref(Barrier* barrier) { intrusive_ptr_add_ref(barrier->pimpl_);