mn_convar.hpp
Go to the documentation of this file.
1 
19 #ifndef MINLIB_ESP32_CONVAR_
20 #define MINLIB_ESP32_CONVAR_
21 
27 #if MN_THREAD_CONFIG_CONDITION_VARIABLE_SUPPORT == MN_THREAD_CONFIG_YES
28 
29 #include "mn_config.hpp"
30 #include "mn_mutex.hpp"
31 #include "mn_autolock.hpp"
32 #include "mn_autounlock.hpp"
33 
34 #include <list>
35 
36 namespace mn {
37  namespace ext {
44  class basic_convar_task;
45 
62  friend class basic_convar_task;
63  public:
68 
72  void signal();
73 
77  void broadcast();
78 
79  inline void notify_one() noexcept { // wake up one waiter
80  signal();
81  }
82 
83  inline void notify_all() noexcept { // wake up all waiters
84  broadcast();
85  }
86 
87  private:
94  void add_list(basic_convar_task *thread);
95  protected:
103  std::list<basic_convar_task*> m_waitList;
104  };
105 
107  }
108 }
109 #endif
110 
111 #endif
Definition: mn_mutex.hpp:37
Definition: mn_convar.hpp:55
void notify_one() noexcept
Definition: mn_convar.hpp:79
mutex_t m_mutex
Definition: mn_convar.hpp:99
void signal()
Definition: mn_convar.cpp:46
void notify_all() noexcept
Definition: mn_convar.hpp:83
void add_list(basic_convar_task *thread)
Definition: mn_convar.cpp:37
std::list< basic_convar_task * > m_waitList
Definition: mn_convar.hpp:103
void broadcast()
Definition: mn_convar.cpp:60
basic_condition_variable()
Definition: mn_convar.cpp:30
Definition: mn_convar_task.hpp:42
#define MN_DEFAULT_CLASS
Definition: mn_copyable.hpp:29
Definition: mn_allocator_typetraits.hpp:25