yield.cpp 327 B

123456789101112131415161718192021222324
  1. #include "platform.h"
  2. #ifdef _win_
  3. #include "winint.h"
  4. #include <process.h>
  5. #else
  6. #include <sched.h>
  7. #endif
  8. void SchedYield() noexcept {
  9. #if defined(_unix_)
  10. sched_yield();
  11. #else
  12. Sleep(0);
  13. #endif
  14. }
  15. void ThreadYield() noexcept {
  16. #if defined(_freebsd_)
  17. pthread_yield();
  18. #else
  19. SchedYield();
  20. #endif
  21. }