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.

85 lines
1.9 KiB

  1. /*
  2. * The timers is an object that stores an alarm
  3. * setting, and an action to be performed when the alarm
  4. * setting is reached. This is an abstract object.
  5. *
  6. * REVISIONS:
  7. * pcy02Dec92: Removed include of typedefs.h
  8. * jod07Dec92: Added new Sorted List to the object.
  9. * pcy14Dec92: Changed Sortable to ApcSortable
  10. * ane11Jan93: Added copy constructor
  11. * ane18Jan93: Implemented Equal operator
  12. * pcy16Jan93: Timers are now in seconds since time in msec is too big
  13. *
  14. */
  15. #define INCL_BASE
  16. #define INCL_DOS
  17. #define INCL_NOPM
  18. #include "cdefine.h"
  19. extern "C" {
  20. #include <time.h>
  21. }
  22. #include "apc.h"
  23. #include "err.h"
  24. #include "sortable.h"
  25. #include "event.h"
  26. #include "update.h"
  27. #include "timer.h"
  28. //
  29. static ULONG theCounter=1;
  30. /*
  31. C+
  32. Name :Timer
  33. Synop :Constructor. This will assign a unique TimerID number
  34. to theTimerID instance variable and will calculate the
  35. system tiem at which the timer will elapse.
  36. */
  37. Timer::Timer(ULONG MilliSecondDelay)
  38. //c-
  39. {
  40. theTimerID =theCounter++;
  41. ULONG cur_time = (ULONG)(time(0));
  42. theAlarmTime = cur_time + MilliSecondDelay;
  43. }
  44. Timer::Timer(RTimer aTimer)
  45. {
  46. theTimerID = aTimer.theTimerID;
  47. theAlarmTime = aTimer.theAlarmTime;
  48. }
  49. INT Timer:: GreaterThan(PApcSortable sortable)
  50. {
  51. if (!sortable) return FALSE;
  52. PTimer timer = (PTimer)sortable;
  53. if (theAlarmTime > timer->GetAlarmTime())
  54. return TRUE;
  55. return FALSE;
  56. }
  57. INT Timer:: LessThan(PApcSortable sortable)
  58. {
  59. if (!sortable) return FALSE;
  60. PTimer timer = (PTimer)sortable;
  61. if (theAlarmTime < timer->GetAlarmTime())
  62. return TRUE;
  63. return FALSE;
  64. }
  65. INT Timer::Equal (RObj aTimerObj) const
  66. {
  67. RTimer aTimer = (RTimer)aTimerObj;
  68. if ((theTimerID == aTimer.theTimerID) &&
  69. (theAlarmTime == aTimer.theAlarmTime))
  70. return TRUE;
  71. return FALSE;
  72. }