Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1.2 KiB

  1. #ifndef PASSPORTTHREAD_HPP
  2. #define PASSPORTTHREAD_HPP
  3. #include <windows.h>
  4. #include <winbase.h>
  5. class PassportThread
  6. {
  7. public:
  8. PassportThread();
  9. // --------------------
  10. // the new thread will
  11. // execute this function
  12. virtual void run() = 0;
  13. // ---------------------
  14. // start a new thread and
  15. // that thread calls run
  16. bool start();
  17. virtual DWORD threadID();
  18. virtual HANDLE threadHandle()
  19. {
  20. return mHandle;
  21. }
  22. virtual ~PassportThread();
  23. // ---------------------------------------
  24. // waits for all the given threads to stop.
  25. // NOTE: the current maximum number of
  26. // threads that can be joined is 64.
  27. static bool join(PassportThread* threads[], int size);
  28. // ---------------------------
  29. // cause the current thread
  30. // to sleep for the specified
  31. // number of milliseconds
  32. static void sleep(long milliseconds);
  33. // --------------------------------
  34. // returns the id of the current
  35. // thread
  36. static DWORD currentThreadID();
  37. private:
  38. DWORD mThreadID;
  39. HANDLE mHandle;
  40. };
  41. #endif // !PASSPORTTHREAD_HPP