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.

129 lines
2.5 KiB

  1. /*++
  2. Copyright (c) 1998 Microsoft Corporation
  3. Module Name:
  4. tpstimer.cpp
  5. Abstract:
  6. Contains Win32 thread pool services timer functions
  7. Contents:
  8. TerminateTimers
  9. SHCreateTimerQueue
  10. (IECreateTimerQueue)
  11. SHDeleteTimerQueue
  12. (IEDeleteTimerQueue)
  13. SHSetTimerQueueTimer
  14. (IESetTimerQueueTimer)
  15. (NTSetTimerQueueTimer)
  16. SHChangeTimerQueueTimer
  17. (IEChangeTimerQueueTimer)
  18. SHCancelTimerQueueTimer
  19. (IECancelTimerQueueTimer)
  20. (NTCancelTimerQueueTimer)
  21. (InitializeTimerThread)
  22. (TimerCleanup)
  23. (CreateDefaultTimerQueue)
  24. (DeleteDefaultTimerQueue)
  25. (CleanupDefaultTimerQueue)
  26. (TimerThread)
  27. (AddTimer)
  28. (ChangeTimer)
  29. (CancelTimer)
  30. Author:
  31. Richard L Firth (rfirth) 10-Feb-1998
  32. Environment:
  33. Win32 user-mode
  34. Notes:
  35. Code reworked in C++ from NT-specific C code written by Gurdeep Singh Pall
  36. (gurdeep)
  37. Revision History:
  38. 10-Feb-1998 rfirth
  39. Created
  40. --*/
  41. #include "priv.h"
  42. #include "threads.h"
  43. #include "tpsclass.h"
  44. //
  45. // functions
  46. //
  47. LWSTDAPI_(HANDLE)
  48. SHCreateTimerQueue(
  49. VOID
  50. )
  51. {
  52. return CreateTimerQueue();
  53. }
  54. LWSTDAPI_(BOOL)
  55. SHDeleteTimerQueue(
  56. IN HANDLE hQueue
  57. )
  58. {
  59. return DeleteTimerQueue(hQueue);
  60. }
  61. LWSTDAPI_(BOOL)
  62. SHChangeTimerQueueTimer(
  63. IN HANDLE hQueue,
  64. IN HANDLE hTimer,
  65. IN DWORD dwDueTime,
  66. IN DWORD dwPeriod
  67. )
  68. {
  69. return ChangeTimerQueueTimer(hQueue, hTimer, dwDueTime, dwPeriod);
  70. }
  71. LWSTDAPI_(BOOL)
  72. SHCancelTimerQueueTimer(
  73. IN HANDLE hQueue,
  74. IN HANDLE hTimer
  75. )
  76. {
  77. return DeleteTimerQueueTimer(hQueue, hTimer, INVALID_HANDLE_VALUE);
  78. }
  79. // these we do alittle wrapping on.
  80. LWSTDAPI_(HANDLE)
  81. SHSetTimerQueueTimer(
  82. IN HANDLE hQueue,
  83. IN WAITORTIMERCALLBACKFUNC pfnCallback,
  84. IN LPVOID pContext,
  85. IN DWORD dwDueTime,
  86. IN DWORD dwPeriod,
  87. IN LPCSTR lpszLibrary OPTIONAL,
  88. IN DWORD dwFlags
  89. )
  90. {
  91. //
  92. // Translate the flags from TPS flags to WT flags.
  93. //
  94. DWORD dwWTFlags = 0;
  95. if (dwFlags & TPS_EXECUTEIO) dwWTFlags |= WT_EXECUTEINIOTHREAD;
  96. if (dwFlags & TPS_LONGEXECTIME) dwWTFlags |= WT_EXECUTELONGFUNCTION;
  97. HANDLE hTimer;
  98. if (CreateTimerQueueTimer(&hTimer, hQueue, pfnCallback, pContext, dwDueTime, dwPeriod, dwWTFlags))
  99. {
  100. return hTimer;
  101. }
  102. return NULL;
  103. }