aboutsummaryrefslogtreecommitdiff
path: root/Src/Wasabi/api/timer/api_timer.h
blob: 4bc8cb8106c002dfc7debba3cba0435271c40359 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#ifndef __TIMER_API_H
#define __TIMER_API_H

// Under linux, the Timer API requires the Linux API

#include <bfc/dispatch.h>
#include <bfc/platform/platform.h>

class TimerClient;

#ifdef _WIN32
typedef UINT_PTR TimerToken ;
#elif defined(__APPLE__)
typedef EventLoopTimerRef TimerToken;
#else
#error port me!
#endif

class timer_api : public Dispatchable 
{
  public:
    TimerToken timer_add(TimerClient *client, intptr_t id, int ms);
    void timer_remove(TimerClient *client, TimerToken token);

  enum {
    TIMER_API_ADD = 1,
    TIMER_API_REMOVE = 11,
  };
};

inline TimerToken timer_api::timer_add(TimerClient *client, intptr_t id, int ms) 
{
  return _call(TIMER_API_ADD, (TimerToken)0, client, id, ms);
}

inline void timer_api::timer_remove(TimerClient *client, TimerToken token) 
{
  _voidcall(TIMER_API_REMOVE, client, token);
}

// {3130D81C-AE1F-4954-9765-698473B627B0}
static const GUID timerApiServiceGuid = 
{ 0x3130d81c, 0xae1f, 0x4954, { 0x97, 0x65, 0x69, 0x84, 0x73, 0xb6, 0x27, 0xb0 } };

extern timer_api *timerApi;

#endif