Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
code simplification + replace a FIXME with an assert
[simgrid.git] / src / kernel / activity / ConditionVariableImpl.hpp
1 /* Copyright (c) 2012-2019. 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_KERNEL_ACTIVITY_CONDITIONVARIABLEIMPL_HPP
7 #define SIMGRID_KERNEL_ACTIVITY_CONDITIONVARIABLEIMPL_HPP
8
9 #include "simgrid/s4u/ConditionVariable.hpp"
10 #include "src/kernel/actor/ActorImpl.hpp"
11 #include <boost/intrusive/list.hpp>
12
13 namespace simgrid {
14 namespace kernel {
15 namespace activity {
16
17 class XBT_PUBLIC ConditionVariableImpl {
18 public:
19   ConditionVariableImpl();
20   ~ConditionVariableImpl();
21
22   actor::SynchroList sleeping_; /* list of sleeping processes */
23   MutexImpl* mutex_ = nullptr;
24   s4u::ConditionVariable cond_;
25
26   void broadcast();
27   void signal();
28   void wait(MutexImpl* mutex, double timeout, actor::ActorImpl* issuer);
29
30 private:
31   std::atomic_int_fast32_t refcount_{1};
32   friend void intrusive_ptr_add_ref(ConditionVariableImpl* cond);
33   friend void intrusive_ptr_release(ConditionVariableImpl* cond);
34 };
35 } // namespace activity
36 } // namespace kernel
37 } // namespace simgrid
38
39 #endif