mn_thread.hpp
Go to the documentation of this file.
1 
21 #ifndef __MINILIB_THREAD_H__
22 #define __MINILIB_THREAD_H__
23 
24 #include "mn_config.hpp"
25 #include "mn_functional.hpp"
26 #include "mn_function.hpp"
27 
28 #include "mn_task.hpp"
29 
30 namespace mn {
31 
32  class basic_thread : public basic_task {
33  public:
34  class id {
35  public:
36 
37  };
40  using func_type = mn::function<int(void*)>;
41 
42 
43  basic_thread(std::string strName, func_type* func,
45  unsigned short usStackDepth = MN_THREAD_CONFIG_MINIMAL_STACK_SIZE) noexcept
46  : base_type(strName, uiPriority, usStackDepth),
47  m_funcTion(func) {}
48 
49 
50  basic_thread(const basic_thread&) = delete;
51  basic_thread& operator=(const basic_thread&) = delete;
52  protected:
53  int on_task() {
54  if(m_funcTion) return m_funcTion(m_userData);
55  else return -127;
56  }
57  private:
59  };
60 
61 }
62 
63 #endif // __MINILIB_THREAD_H__
Wrapper class around FreeRTOS's implementation of a task.
Definition: mn_task.hpp:88
priority
Task priority.
Definition: mn_task.hpp:93
basic_task() noexcept
Definition: mn_task.hpp:117
xTaskHandle native_handle_type
Definition: mn_task.hpp:111
Definition: mn_thread.hpp:32
func_type m_funcTion
Definition: mn_thread.hpp:58
int on_task()
Implementation of your actual task code. You must override this function.
Definition: mn_thread.hpp:53
basic_thread(const basic_thread &)=delete
basic_task base_type
Definition: mn_thread.hpp:38
basic_thread & operator=(const basic_thread &)=delete
basic_thread(std::string strName, func_type *func, basic_task::priority uiPriority=basic_task::priority::Normal, unsigned short usStackDepth=MN_THREAD_CONFIG_MINIMAL_STACK_SIZE) noexcept
Definition: mn_thread.hpp:43
Definition: mn_thread.hpp:34
#define MN_THREAD_CONFIG_MINIMAL_STACK_SIZE
Definition: mn_config.hpp:219
Definition: mn_allocator_typetraits.hpp:25
Definition: mn_function.hpp:34