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.

79 lines
1.9 KiB

  1. // Gemplus (C) 1999
  2. // Version 1.0
  3. // Author: Sergey Ivanov
  4. // Date of creation - 18.05.1999
  5. // Change log:
  6. //
  7. #ifndef __THREAD__
  8. #define __THREAD__
  9. #include "generic.h"
  10. #include "kernel.h"
  11. #pragma PAGEDCODE
  12. class CUSBReader;//TOBE REMOVED
  13. class CTimer;
  14. //class CThread;
  15. typedef
  16. NTSTATUS
  17. (*PCLIENT_THREAD_ROUTINE) (
  18. IN PVOID RoutineContext
  19. );
  20. // Default thread pooling interval in ms
  21. #define DEFAULT_THREAD_POOLING_INTERVAL 500
  22. class CThread
  23. {
  24. public:
  25. NTSTATUS m_Status;
  26. SAFE_DESTRUCTORS();
  27. virtual VOID dispose(){self_delete();};
  28. private:
  29. KEVENT evKill; // set to kill polling thread
  30. KEVENT evStart; // set when requested to start, clear when need to stop pooling
  31. KEVENT evIdle; // Signals that thread stopped and at Idle state
  32. KEVENT evStopped; // set when requested to close thread
  33. PKTHREAD thread; // polling thread object
  34. KSEMAPHORE smOnDemandStart;// request to repeate operation if semaphore is at Signal state
  35. BOOLEAN StopRequested;
  36. BOOLEAN ThreadActive;
  37. CDebug* debug;
  38. CEvent* event;
  39. CSystem* system;
  40. CTimer* timer;
  41. CSemaphore* semaphore;
  42. ULONG PoolingTimeout;
  43. PCLIENT_THREAD_ROUTINE pfClientThreadFunction;
  44. PVOID ClientContext;
  45. //CDevice* device;
  46. //CUSBReader* device;
  47. protected:
  48. CThread(){};
  49. virtual ~CThread();
  50. public:
  51. //CThread(CDevice* device);
  52. //CThread(CUSBReader* device);
  53. CThread(PCLIENT_THREAD_ROUTINE ClientThreadFunction, PVOID ClientContext,
  54. ULONG delay=DEFAULT_THREAD_POOLING_INTERVAL);
  55. static VOID ThreadFunction(CThread* thread);
  56. VOID ThreadRoutine(PVOID context) ;
  57. PKEVENT getKillObject(){return &evKill;};
  58. PKEVENT getStartObject(){return &evStart;};
  59. VOID kill();
  60. VOID start();
  61. VOID stop();
  62. BOOL isThreadActive();
  63. VOID setPoolingInterval(ULONG delay);
  64. // Force to call thread function...
  65. // This is on demand start.
  66. VOID callThreadFunction();
  67. };
  68. #endif//THREAD