You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
784 B

2 years ago
  1. #pragma once
  2. #include "osbasic_h.hpp"
  3. namespace iflytop {
  4. typedef function<void()> zosthread_cb_t;
  5. class ZThread {
  6. public:
  7. const char* m_name;
  8. size_t m_stacksize;
  9. osPriority m_uxPriority;
  10. bool m_threadisworkingFlag = false;
  11. bool m_threadisWaitingForStopFlag = false;
  12. bool m_threadisworkingFlagCallSide = false;
  13. zosthread_cb_t m_taskfunction;
  14. EventGroupHandle_t m_zthreadstartworkevent;
  15. osThreadId m_defaultTaskHandle;
  16. SemaphoreHandle_t m_lock;
  17. public:
  18. void init(const char* threadname, int stack_size = 1024, osPriority priority = osPriorityNormal);
  19. void start(zosthread_cb_t cb);
  20. void stop();
  21. bool getExitFlag() { return !m_threadisworkingFlagCallSide; }
  22. void sleep(uint32_t ms);
  23. void wake();
  24. };
  25. } // namespace iflytop