SCTP 库的简述和代码 (4)
2 定时器 简单的时间轮. 使用时间轮是因为, 定时器数目可能比较大. 要求使用者周期性调用, p_timer_wheel_hb 缺点是, 不精确. /* Hash table for hold timer list */ static list_header wheel_slot[WHEEL_ELEM]; static unsigned int svd_tick; static int cur_slot = 0; #ifndef WIN32 unsigned int GetTickCount() { struct timeval current; unsigned int cur_time; gettimeofday(¤t, NULL); cur_time = current.tv_sec*1000 + current.tv_usec/1000; return cur_time; } #endif unsigned int get_cur_time() { return GetTickCount(); } void p_timer_restart (p_timer_t *new_timer) { int target_slot; list_header *timer_list; assert(new_timer); target_slot = (cur_slot +