threads.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #ifndef THREADS_H__
  2. #define THREADS_H__
  3. #if _MSC_VER >= 1000
  4. #pragma once
  5. #endif
  6. #define MAX_THREADS 64
  7. typedef enum
  8. {
  9. eThreadPriorityLow = -1,
  10. eThreadPriorityNormal,
  11. eThreadPriorityHigh
  12. }
  13. q_threadpriority;
  14. typedef void (*q_threadfunction) (int);
  15. #ifdef SYSTEM_WIN32
  16. #define DEFAULT_NUMTHREADS -1
  17. #endif
  18. #ifdef SYSTEM_POSIX
  19. #define DEFAULT_NUMTHREADS 1
  20. #endif
  21. #define DEFAULT_THREAD_PRIORITY eThreadPriorityNormal
  22. extern int g_numthreads;
  23. extern q_threadpriority g_threadpriority;
  24. extern void ThreadSetPriority(q_threadpriority type);
  25. extern void ThreadSetDefault();
  26. extern int GetThreadWork();
  27. extern void ThreadLock();
  28. extern void ThreadUnlock();
  29. extern void RunThreadsOnIndividual(int workcnt, bool showpacifier, q_threadfunction);
  30. extern void RunThreadsOn(int workcnt, bool showpacifier, q_threadfunction);
  31. #ifdef ZHLT_NETVIS
  32. extern void threads_InitCrit();
  33. extern void threads_UninitCrit();
  34. #endif
  35. #define NamedRunThreadsOn(n,p,f) { Log("%s\n", #f ":"); RunThreadsOn(n,p,f); }
  36. #define NamedRunThreadsOnIndividual(n,p,f) { Log("%s\n", #f ":"); RunThreadsOnIndividual(n,p,f); }
  37. #endif //**/ THREADS_H__