1
0

nxthread.c 629 B

12345678910111213141516171819202122232425
  1. #include "nxthread.h"
  2. #include "foundation/error.h"
  3. int NXThreadCreate(nx_thread_t *thread, nx_thread_func_t thread_function, nx_thread_parameter_t parameter)
  4. {
  5. *thread = (nx_thread_t)CreateThread(0, 0, thread_function, parameter, 0, 0);
  6. return NErr_Success;
  7. }
  8. int NXThreadJoin(nx_thread_t t, nx_thread_return_t *retval)
  9. {
  10. if (!t)
  11. return NErr_NullPointer;
  12. WaitForSingleObject((HANDLE)t, INFINITE);
  13. if (retval)
  14. GetExitCodeThread((HANDLE)t, retval);
  15. CloseHandle((HANDLE)t);
  16. return NErr_Success;
  17. }
  18. int NXThreadCurrentSetPriority(int priority)
  19. {
  20. SetThreadPriority(GetCurrentThread(), priority);
  21. return NErr_Success;
  22. }