luat_rtos_win32_task.c 891 B

123456789101112131415161718192021222324252627282930313233343536
  1. #include "luat_base.h"
  2. #include "luat_rtos.h"
  3. #include "windows.h"
  4. #define thread_type HANDLE
  5. #define thread_id_type DWORD
  6. #define thread_return_type DWORD
  7. #define thread_fn LPTHREAD_START_ROUTINE
  8. #define cond_type HANDLE
  9. #define sem_type HANDLE
  10. #undef ETIMEDOUT
  11. #define ETIMEDOUT WSAETIMEDOUT
  12. #define LUAT_LOG_TAG "thread"
  13. #include "luat_log.h"
  14. static void task_proxy(void* params) {
  15. luat_thread_t* thread = (luat_thread_t*)params;
  16. thread->entry(thread->userdata);
  17. }
  18. LUAT_RET luat_thread_start(luat_thread_t* thread) {
  19. thread_type thread = NULL;
  20. thread = CreateThread(NULL, 0, task_proxy, thread, 0, NULL);
  21. CloseHandle(thread);
  22. LLOGD("thread start fail %d", ret);
  23. return LUAT_ERR_FAIL;
  24. }
  25. LUAT_RET luat_thread_stop(luat_thread_t* thread) {
  26. return LUAT_ERR_FAIL;
  27. }
  28. LUAT_RET luat_thread_delete(luat_thread_t* thread) {
  29. return LUAT_ERR_FAIL;
  30. }