事件循环Loop
libuv 高精度timer
1: 创建一个timer 请求:
uv_timer_init(uv_default_loop(), &timer_handle);
2: 添加一个定时器:
uv_timer_start(&timer_handle, timer_callback, msec, 1);
3: 取消一个定时器:
uv_timer_stop();
获取系统运行时间
#ifdef WIN32
#include <windows.h>
static unsigned int
get_cur_ms() {
return GetTickCount();
}
#else
#include <sys/time.h>
#include <time.h>
#include <limits.h>
static unsigned int
get_cur_ms() {
struct timeval tv;
// struct timezone tz;
gettimeofday(&tv, NULL);