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.

54 lines
1.7 KiB

  1. /*==========================================================================
  2. *
  3. * Copyright (C) 2002 Microsoft Corporation. All Rights Reserved.
  4. *
  5. * File: dvtimer.h
  6. * Content: Defintion of DvTimer class.
  7. * This class is a replacement for the original Timer class (by rodtoll) which used multimedia timers
  8. * This replaces the multimedia timers with the dplay8 threadpool timers, whilst maintaining
  9. * a similar interface to the original Timer class
  10. *
  11. * History:
  12. * Date By Reason
  13. * ==== == ======
  14. * 05-06-02 simonpow Created
  15. *
  16. ***************************************************************************/
  17. #ifndef __DVTIMER_H__
  18. #define __DVTIMER_H__
  19. //number of msec we sleep whilst spinning in our cancel timer loop
  20. static const DWORD DvTimer_SleepPeriodInCancelSpin=5;
  21. //prototype for the callback user of timer can specify
  22. typedef void (*DvTimerCallback)(void * pvUserData);
  23. class DvTimer
  24. {
  25. public:
  26. //default c'tor. Establishes timer in uncreated state
  27. DvTimer(void);
  28. //default d'tor. If timer has been created this will cancel it and not return until it has
  29. ~DvTimer(void);
  30. //create timer to fire every 'dwPeriod' msec, calling 'pfnCallback' with 'pvUserData'
  31. //when it does. Returns TRUE for sucess
  32. BOOL Create (DWORD dwPeriod, void * pvUserData, DvTimerCallback pfnCallback);
  33. protected:
  34. static void WINAPI ThreadpoolTimerCallbackStatic(void * const pvContext,
  35. void * const pvTimerData, const UINT uiTimerUnique);
  36. DvTimerCallback m_pfnUserCallback;
  37. void * m_pvUserData;
  38. DWORD m_dwPeriod;
  39. void * m_pvTimerData;
  40. volatile UINT m_uiTimerUnique;
  41. IDirectPlay8ThreadPoolWork * m_pThreadPool;
  42. };
  43. #endif // #ifndef __DVTIMER_H__