swtimer.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. /************************************************************************
  2. * AUTHOR: NiuJiuRu
  3. * FILENAME: swtimer.h
  4. * CONTENT: 定时器
  5. * NOTE:
  6. * HISTORY:
  7. * 1, [2010-09-14] created by NiuJiuRu
  8. ***********************************************************************/
  9. #ifndef __SWTIMER_H__
  10. #define __SWTIMER_H__
  11. #ifdef __cplusplus
  12. extern "C"
  13. {
  14. #endif
  15. /* 定时器的节拍函数(用户回调), "wParam"指向该定时器, "lParam"暂未使用 */
  16. typedef void (*PTimerProc)(unsigned long wParam, unsigned long lParam);
  17. /* 创建定时器(ms), 成功后默认处于暂停状态 */
  18. void *sw_timer_create(const char *name, int period, PTimerProc proc, unsigned long wParam, unsigned long lParam);
  19. /* 销毁定时器, 超时前尝试安全的销毁, 超时后则强制销毁 */
  20. void sw_timer_destroy(void *hTimer, int timeout);
  21. /* 暂停运行定时器 */
  22. void sw_timer_pause(void *hTimer);
  23. /* 继续运行定时器 */
  24. void sw_timer_resume(void *hTimer);
  25. /* 设置定时器的节拍时间(ms) */
  26. void sw_timer_setPeriod(void *hTimer, int period);
  27. #ifdef __cplusplus
  28. }
  29. #endif
  30. #endif /* __SWTIMER_H__ */