1 /* Copyright (c) 2018-2019. The SimGrid Team. All rights reserved. */
3 /* This program is free software; you can redistribute it and/or modify it
4 * under the terms of the license (GNU LGPL) which comes with this package. */
6 #ifndef SIMGRID_S4U_BARRIER_HPP
7 #define SIMGRID_S4U_BARRIER_HPP
9 #include <simgrid/barrier.h>
10 #include <simgrid/chrono.hpp>
11 #include <simgrid/forward.h>
12 #include <simgrid/s4u/ConditionVariable.hpp>
13 #include <simgrid/s4u/Mutex.hpp>
21 class XBT_PUBLIC Barrier {
24 ConditionVariablePtr cond_;
25 unsigned int expected_actors_;
26 unsigned int arrived_actors_ = 0;
29 std::atomic_int_fast32_t refcount_{0};
32 explicit Barrier(unsigned int count);
35 Barrier(Barrier const&) = delete;
36 Barrier& operator=(Barrier const&) = delete;
39 static BarrierPtr create(unsigned int expected_actors);
44 friend XBT_PUBLIC void intrusive_ptr_add_ref(Barrier* barrier);
45 friend XBT_PUBLIC void intrusive_ptr_release(Barrier* barrier);
49 } // namespace simgrid