Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[S4U] Cosmetics
[simgrid.git] / include / simgrid / s4u / Barrier.hpp
1 /* Copyright (c) 2018. The SimGrid Team. All rights reserved.          */
2
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. */
5
6 #ifndef SIMGRID_S4U_BARRIER_HPP
7 #define SIMGRID_S4U_BARRIER_HPP
8
9 #include "simgrid/s4u/ConditionVariable.hpp"
10 #include <simgrid/chrono.hpp>
11 #include <simgrid/s4u/Mutex.hpp>
12
13 #include <future>
14
15 namespace simgrid {
16 namespace s4u {
17
18 class XBT_PUBLIC Barrier {
19 private:
20   MutexPtr mutex_;
21   ConditionVariablePtr cond_;
22   unsigned int expected_processes_;
23   unsigned int arrived_processes_ = 0;
24
25 public:
26   explicit Barrier(unsigned int count);
27   ~Barrier()              = default;
28   Barrier(Barrier const&) = delete;
29   Barrier& operator=(Barrier const&) = delete;
30
31   int wait();
32 };
33 }
34 } // namespace simgrid::s4u
35
36 #endif