代码拉取完成,页面将自动刷新
同步操作将从 libhv/libhv 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#include "hloop.h"
#include "hbase.h"
void on_timer(htimer_t* timer) {
printf("time=%llus on_timer\n", LLU(hloop_now(hevent_loop(timer))));
}
// test htimer_add
void on_timer_add(htimer_t* timer) {
printf("time=%llus on_timer_add\n", LLU(hloop_now(hevent_loop(timer))));
htimer_add(hevent_loop(timer), on_timer_add, 1000, 1);
}
// test htimer_del
void on_timer_del(htimer_t* timer) {
printf("time=%llus on_timer_del\n", LLU(hloop_now(hevent_loop(timer))));
htimer_del(timer);
}
// test htimer_reset
void on_timer_reset(htimer_t* timer) {
printf("time=%llus on_timer_reset\n", LLU(hloop_now(hevent_loop(timer))));
htimer_reset((htimer_t*)hevent_userdata(timer), 0);
}
// test hloop_stop
void on_timer_quit(htimer_t* timer) {
printf("time=%llus on_timer_quit\n", LLU(hloop_now(hevent_loop(timer))));
hloop_stop(hevent_loop(timer));
}
// test cron
void cron_hourly(htimer_t* timer) {
time_t tt = time(NULL);
printf("time=%llus cron_hourly: %s\n", LLU(hloop_now(hevent_loop(timer))), ctime(&tt));
}
int main() {
HV_MEMCHECK;
hloop_t* loop = hloop_new(0);
htimer_add(loop, on_timer_add, 1000, 1);
htimer_add(loop, on_timer_del, 1000, 10);
htimer_t* reseted = htimer_add(loop, on_timer, 5000, 1);
htimer_t* reset = htimer_add(loop, on_timer_reset, 1000, 5);
hevent_set_userdata(reset, reseted);
// cron_hourly next triggered in one minute
int minute = time(NULL)%3600/60;
htimer_add_period(loop, cron_hourly, minute+1, -1, -1, -1, -1, INFINITE);
// quit application after 1 min
htimer_add(loop, on_timer_quit, 60000, 1);
printf("time=%llus begin\n", LLU(hloop_now(loop)));
hloop_run(loop);
printf("time=%llus stop\n", LLU(hloop_now(loop)));
hloop_free(&loop);
return 0;
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。