老大前几天提到libuv,我只看过一点libevent, 听说过libev,没听说过libuv,查了一下才知道libuv。
先到github git clone 源码,编译,测试,看测试代码
头文件uv.h定时器部分的函数,头文件有详细的注释
* uv_timer_t is a subclass of uv_handle_t.
*
* Used to get woken up at a specified time in the future.
*/
struct uv_timer_s {
UV_HANDLE_FIELDS
UV_TIMER_PRIVATE_FIELDS
};
UV_EXTERN int uv_timer_init(uv_loop_t*, uv_timer_t* handle);
/*
* Start the timer. `timeout` and `repeat` are in milliseconds.
*
* If timeout is zero, the callback fires on the next tick of the event loop.
*
* If repeat is non-zero, the callback fires first after timeout milliseconds
* and then repeatedly after repeat milliseconds.
*/
UV_EXTERN int uv_timer_start(uv_timer_t* handle,