1
0

api_timer.h 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #ifndef __TIMER_API_H
  2. #define __TIMER_API_H
  3. // Under linux, the Timer API requires the Linux API
  4. #include <bfc/dispatch.h>
  5. #include <bfc/platform/platform.h>
  6. class TimerClient;
  7. #ifdef _WIN32
  8. typedef UINT_PTR TimerToken ;
  9. #elif defined(__APPLE__)
  10. typedef EventLoopTimerRef TimerToken;
  11. #else
  12. #error port me!
  13. #endif
  14. class timer_api : public Dispatchable
  15. {
  16. public:
  17. TimerToken timer_add(TimerClient *client, intptr_t id, int ms);
  18. void timer_remove(TimerClient *client, TimerToken token);
  19. enum {
  20. TIMER_API_ADD = 1,
  21. TIMER_API_REMOVE = 11,
  22. };
  23. };
  24. inline TimerToken timer_api::timer_add(TimerClient *client, intptr_t id, int ms)
  25. {
  26. return _call(TIMER_API_ADD, (TimerToken)0, client, id, ms);
  27. }
  28. inline void timer_api::timer_remove(TimerClient *client, TimerToken token)
  29. {
  30. _voidcall(TIMER_API_REMOVE, client, token);
  31. }
  32. // {3130D81C-AE1F-4954-9765-698473B627B0}
  33. static const GUID timerApiServiceGuid =
  34. { 0x3130d81c, 0xae1f, 0x4954, { 0x97, 0x65, 0x69, 0x84, 0x73, 0xb6, 0x27, 0xb0 } };
  35. extern timer_api *timerApi;
  36. #endif