在上篇文章中介绍关于event_dispatch的大体框架,这里对其中的几个重要的函数解释说明
1、timeout_correct(base,&tv)
static void
889 timeout_correct(struct event_base *base, struct timeval *tv)
890 {
891 struct event **pev;
892 unsigned int size;
893 struct timeval off;
894
895 if (use_monotonic)
896 return;
897
898 /* Check if time is running backwards */
899 gettime(base, tv);
900 if (evutil_timercmp(tv, &base->event_tv, >=)) {
901 base->event_tv = *tv;
902 return;
903 }
904
905 event_debug(("%s: time is running backwards, corrected",
906 __func__));
907 evutil_timersub(&base->event_tv, tv, &off);
908
909 /*
910 * We can modify the key element of the node without destroying
911 * the key, beause we apply it to all in the right order.
912 */
913 pev = base->timeheap.p;
914 size = base->timeheap.n;
915