threads.c 512 B

12345678910111213141516171819202122
  1. #include "pocketpy/export.h"
  2. #include "pocketpy/common/threads.h"
  3. #if PK_USE_PTHREADS
  4. bool c11_thrd_create(c11_thrd_t* thrd, c11_thrd_retval_t (*func)(void*), void* arg) {
  5. int res = pthread_create(thrd, NULL, func, arg);
  6. return res == 0;
  7. }
  8. void c11_thrd_yield() { sched_yield(); }
  9. #else
  10. bool c11_thrd_create(c11_thrd_t* thrd, c11_thrd_retval_t (*func)(void*), void* arg) {
  11. int res = thrd_create(thrd, func, arg);
  12. return res == thrd_success;
  13. }
  14. void c11_thrd_yield() { thrd_yield(); }
  15. #endif