Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
start modernizing ConditionVariableImpl
[simgrid.git] / src / kernel / activity / ConditionVariableImpl.hpp
1 /* Copyright (c) 2012-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_KERNEL_ACTIVITY_CONDITIONVARIABLEIMPL_HPP
7 #define SIMGRID_KERNEL_ACTIVITY_CONDITIONVARIABLEIMPL_HPP
8
9 #include "simgrid/s4u/ConditionVariable.hpp"
10 #include "src/simix/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   simgrid::kernel::actor::SynchroList sleeping; /* list of sleeping processes */
23   smx_mutex_t mutex = nullptr;
24   simgrid::s4u::ConditionVariable cond_;
25
26   void broadcast();
27   void signal();
28
29 private:
30   std::atomic_int_fast32_t refcount_{1};
31   friend void intrusive_ptr_add_ref(ConditionVariableImpl* cond);
32   friend void intrusive_ptr_release(ConditionVariableImpl* cond);
33 };
34 } // namespace activity
35 } // namespace kernel
36 } // namespace simgrid
37 XBT_PRIVATE smx_cond_t SIMIX_cond_init();
38
39 // simcall handlers
40 XBT_PRIVATE void simcall_HANDLER_cond_signal(smx_simcall_t simcall, smx_cond_t cond);
41 XBT_PRIVATE void simcall_HANDLER_cond_broadcast(smx_simcall_t simcall, smx_cond_t cond);
42
43 #endif