代码拉取完成,页面将自动刷新
#define USE_TIMER_LIST 1
#define USE_TIMER_HEAP 0
#define USE_TIMER_WHEEL 0
#if USE_TIMER_LIST
#include "timer_list.h"
#define timer_t ltimer_t
#define timer_mgr_t ltimer_mgr_t
#elif USE_TIMER_HEAP
#include "timer_heap.h"
#define timer_t htimer_t
#define timer_mgr_t htimer_mgr_t
#elif USE_TIMER_WHEEL
#include "timer_wheel.h"
#define timer_t wtimer_t
#define timer_mgr_t wtimer_mgr_t
#endif
#include <stdio.h>
static int ticks = 0;
void on_timer(timer_t* timer) {
static int counter = 0;
printf("ticks(%d) counter(%d)\n", ticks, ++counter);
if (counter == 10) {
timer_stop(timer);
}
}
int main() {
timer_mgr_t timer_mgr;
timer_mgr_init(&timer_mgr, 0);
timer_t timer;
timer_start(&timer_mgr, &timer, on_timer, 10, 5);
for (ticks = 0; ticks < 100; ++ticks) {
timer_tick(&timer_mgr, ticks);
}
return 0;
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。