📄 wxtimer.h
字号:
/* * This piece of code is totally free. If any pitfalls found, * please feel free to contact me at jetmotor@21cn.com * THANKS A LOT! */#ifndef _WXTIMER_H#define _WXTIMER_H#include <pthread.h>#include "list.h"#include "types.h"struct rb_node{ struct rb_node *rb_parent; int rb_color;#define RB_RED 1#define RB_BLACK 2 struct rb_node *rb_right; struct rb_node *rb_left;};#define rb_entry(ptr, type, member) \ ((type *)((char *)(ptr)-(unsigned long)(&((type *)0)->member)))struct rb_root{ struct rb_node *rb_node;};typedef struct wxtimer_s{ struct list_head link; struct rb_node rb_link; uint8_t type;#define WXTIMER_TRIGGER 1#define WXTIMER_PERIODIC 2/* uint8_t stat;#define WXTIMER_RUNNING 1#define WXTIMER_PAUSE 2*/ uint32_t count; uint32_t timestamp; /* sort by timestamp and future, from small to large */ uint32_t future; uint32_t arga; void *argb; void (*action)(uint32_t arga, void *argb);}wxtimer_t;struct wxtimer_tree_s{ pthread_mutex_t mutex; uint32_t nr; struct rb_root rb_root; struct rb_node *rb_first; /* the least timestamp one */};extern uint32_t jiffies;extern int32_t wxtimer_init();extern int32_t wxtmpool_init();extern void * do_task_timer(void *arg);extern wxtimer_t *get_timer(uint8_t type, uint32_t count, uint32_t arga, void *argb, void (*action)(uint32_t, void *));extern int32_t start_timer(wxtimer_t *timer);extern int32_t cancel_timer(wxtimer_t *timer);extern int32_t put_timer(wxtimer_t *timer);#endif /* WXTIMER_H */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -