diff options
Diffstat (limited to 'src/common/timer.h')
-rw-r--r-- | src/common/timer.h | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/src/common/timer.h b/src/common/timer.h index e007e9611..4fa4a3c2d 100644 --- a/src/common/timer.h +++ b/src/common/timer.h @@ -8,28 +8,29 @@ #include "../common/cbasetypes.h" #endif -#define BASE_TICK 5 +#define DIFF_TICK(a,b) ((int)((a)-(b))) + +#define INVALID_TIMER -1 +// timer flags #define TIMER_ONCE_AUTODEL 0x01 #define TIMER_INTERVAL 0x02 #define TIMER_REMOVE_HEAP 0x10 -#define DIFF_TICK(a,b) ((int)((a)-(b))) - -#define INVALID_TIMER -1 - // Struct declaration -typedef int (*TimerFunc)(int,unsigned int,int,int); +typedef int (*TimerFunc)(int tid, unsigned int tick, int id, int data); struct TimerData { unsigned int tick; TimerFunc func; - int id; - int data; int type; int interval; int heap_pos; + + // general-purpose storage + int id; + int data; }; // Function prototype declaration @@ -37,21 +38,19 @@ struct TimerData { unsigned int gettick(void); unsigned int gettick_nocache(void); -int add_timer(unsigned int,TimerFunc f,int,int); +int add_timer(unsigned int tick, TimerFunc func, int id, int data); int add_timer_interval(unsigned int tick, TimerFunc func, int id, int data, int interval); -int delete_timer(int,TimerFunc f); - -int addtick_timer(int tid,unsigned int tick); -int settick_timer(int tid,unsigned int tick); -struct TimerData *get_timer(int tid); +struct TimerData* get_timer(int tid); +int delete_timer(int tid, TimerFunc func); -int do_timer(unsigned int tick); +int addtick_timer(int tid, unsigned int tick); +int settick_timer(int tid, unsigned int tick); int add_timer_func_list(TimerFunc func, char* name); -char* search_timer_func_list(TimerFunc f); unsigned long get_uptime(void); +int do_timer(); void timer_init(void); void timer_final(void); |