root/src/common/timer.h @ 15

Revision 1, 1.3 kB (checked in by jinshiro, 17 years ago)
Line 
1// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
2// For more information, see LICENCE in the main folder
3
4#ifndef _TIMER_H_
5#define _TIMER_H_
6
7#ifndef _CBASETYPES_H_
8#include "../common/cbasetypes.h"
9#endif
10
11#define DIFF_TICK(a,b) ((int)((a)-(b)))
12
13#define INVALID_TIMER -1
14
15// timer flags
16#define TIMER_ONCE_AUTODEL 0x01
17#define TIMER_INTERVAL     0x02
18#define TIMER_REMOVE_HEAP  0x10
19
20// Struct declaration
21
22typedef int (*TimerFunc)(int tid, unsigned int tick, int id, intptr data);
23
24struct TimerData {
25        unsigned int tick;
26        TimerFunc func;
27        int type;
28        int interval;
29        int heap_pos;
30
31        // general-purpose storage
32        int id; 
33        intptr data;
34};
35
36// Function prototype declaration
37
38unsigned int gettick(void);
39unsigned int gettick_nocache(void);
40
41int add_timer(unsigned int tick, TimerFunc func, int id, intptr data);
42int add_timer_interval(unsigned int tick, TimerFunc func, int id, intptr data, int interval);
43struct TimerData* get_timer(int tid);
44int delete_timer(int tid, TimerFunc func);
45
46int addtick_timer(int tid, unsigned int tick);
47int settick_timer(int tid, unsigned int tick);
48
49int add_timer_func_list(TimerFunc func, char* name);
50
51unsigned long get_uptime(void);
52
53int do_timer(unsigned int tick);
54void timer_init(void);
55void timer_final(void);
56
57#endif /* _TIMER_H_ */
Note: See TracBrowser for help on using the browser.