RakThread.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /*
  2. * Copyright (c) 2014, Oculus VR, Inc.
  3. * All rights reserved.
  4. *
  5. * This source code is licensed under the BSD-style license found in the
  6. * LICENSE file in the root directory of this source tree. An additional grant
  7. * of patent rights can be found in the PATENTS file in the same directory.
  8. *
  9. */
  10. #ifndef __RAK_THREAD_H
  11. #define __RAK_THREAD_H
  12. #if defined(_WIN32_WCE)
  13. #include "WindowsIncludes.h"
  14. #endif
  15. #include "Export.h"
  16. #if defined(WINDOWS_PHONE_8) || defined(WINDOWS_STORE_RT)
  17. #include "../DependentExtensions/WinPhone8/ThreadEmulation.h"
  18. using namespace ThreadEmulation;
  19. #endif
  20. namespace RakNet
  21. {
  22. /// To define a thread, use RAK_THREAD_DECLARATION(functionName);
  23. #if defined(_WIN32_WCE) || defined(WINDOWS_PHONE_8) || defined(WINDOWS_STORE_RT)
  24. #define RAK_THREAD_DECLARATION(functionName) DWORD WINAPI functionName(LPVOID arguments)
  25. #elif defined(_WIN32)
  26. #define RAK_THREAD_DECLARATION(functionName) unsigned __stdcall functionName( void* arguments )
  27. #else
  28. #define RAK_THREAD_DECLARATION(functionName) void* functionName( void* arguments )
  29. #endif
  30. class RAK_DLL_EXPORT RakThread
  31. {
  32. public:
  33. /// Create a thread, simplified to be cross platform without all the extra junk
  34. /// To then start that thread, call RakCreateThread(functionName, arguments);
  35. /// \param[in] start_address Function you want to call
  36. /// \param[in] arglist Arguments to pass to the function
  37. /// \return 0=success. >0 = error code
  38. /*
  39. nice value Win32 Priority
  40. -20 to -16 THREAD_PRIORITY_HIGHEST
  41. -15 to -6 THREAD_PRIORITY_ABOVE_NORMAL
  42. -5 to +4 THREAD_PRIORITY_NORMAL
  43. +5 to +14 THREAD_PRIORITY_BELOW_NORMAL
  44. +15 to +19 THREAD_PRIORITY_LOWEST
  45. */
  46. #if defined(_WIN32_WCE) || defined(WINDOWS_PHONE_8) || defined(WINDOWS_STORE_RT)
  47. static int Create( LPTHREAD_START_ROUTINE start_address, void *arglist, int priority=0);
  48. #elif defined(_WIN32)
  49. static int Create( unsigned __stdcall start_address( void* ), void *arglist, int priority=0);
  50. #else
  51. static int Create( void* start_address( void* ), void *arglist, int priority=0);
  52. #endif
  53. };
  54. }
  55. #endif
粤ICP备19079148号