Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Reduce the amount of header files loading xbt/string.hpp
[simgrid.git] / src / kernel / activity / BarrierImpl.hpp
index 44736cd..ed69576 100644 (file)
 #include "src/kernel/activity/ActivityImpl.hpp"
 #include "src/kernel/actor/ActorImpl.hpp"
 #include "src/kernel/actor/SynchroObserver.hpp"
+#include "xbt/string.hpp"
 
-namespace simgrid {
-namespace kernel {
-namespace activity {
+namespace simgrid::kernel::activity {
 /** Barrier Acquisition: the act / process of acquiring the barrier.
  *
  * This is the asynchronous activity associated to Barriers. See the doc of MutexImpl for more details on the rationnal.
@@ -46,7 +45,6 @@ class XBT_PUBLIC BarrierImpl {
   std::atomic_int_fast32_t refcount_{1};
   s4u::Barrier piface_;
   unsigned int expected_actors_;
-  // std::vector<actor::ActorImpl*> arrived_actors_;
   std::deque<BarrierAcquisitionImplPtr> ongoing_acquisitions_;
   static unsigned next_id_;
   unsigned id_ = next_id_++;
@@ -55,7 +53,7 @@ class XBT_PUBLIC BarrierImpl {
   friend s4u::Barrier;
 
 public:
-  BarrierImpl(int expected_actors) : piface_(this), expected_actors_(expected_actors) {}
+  explicit BarrierImpl(int expected_actors) : piface_(this), expected_actors_(expected_actors) {}
   BarrierImpl(BarrierImpl const&) = delete;
   BarrierImpl& operator=(BarrierImpl const&) = delete;
 
@@ -75,8 +73,11 @@ public:
   }
 
   s4u::Barrier& get_iface() { return piface_; }
+
+  std::string to_string() const
+  {
+    return xbt::string_printf("Barrier %u: %zu of %u", id_, ongoing_acquisitions_.size(), expected_actors_);
+  }
 };
-} // namespace activity
-} // namespace kernel
-} // namespace simgrid
+} // namespace simgrid::kernel::activity
 #endif