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.

33 lines
652 B

  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_threadisworking;
  11. bool m_expect_stop;
  12. zosthread_cb_t m_taskfunction;
  13. EventGroupHandle_t m_zthreadstartworkevent;
  14. osThreadId m_defaultTaskHandle;
  15. SemaphoreHandle_t m_lock;
  16. public:
  17. void init(const char* threadname, int stack_size = 1024, osPriority priority = osPriorityNormal);
  18. void start(zosthread_cb_t cb);
  19. void stop();
  20. bool isExpectStop();
  21. void sleep(uint32_t ms);
  22. void wake();
  23. };
  24. } // namespace iflytop