/* Process time events */static int processTimeEvents(aeEventLoop *eventLoop) { int processed = 0; aeTimeEvent *te; long long maxId; time_t now = time(NULL); /* If the system clock is moved to the future, and then set back to the * right value, time events may be delayed in a random way. Often this * means that scheduled operations will not be performed soon enough. * * Here we try to detect system clock skews, and force all the time * events to be processed ASAP when this happens: the idea is that * processing events earlier is less dangerous than delaying them * indefinitely, and practice suggests it is. */ if (now < eventLoop->lastTime) { te = eventLoop->timeEventHead; while(te) { te->when_sec = 0; te = te->next; } } eventLoop->lastTime = now; te = eventLoop->timeEventHead; maxId = eventLoop->timeEventNextId-1; while(te) { long now_sec, now_ms; long long id; if (te->id > maxId) { te = te->next; continue; } aeGetTim
redis源码--processTimeEvents时间事件
最新推荐文章于 2022-12-24 15:50:15 发布
该博客详细解析了Redis中processTimeEvents函数的工作原理,探讨了如何处理时间事件,以及在系统时钟发生偏移时如何确保事件及时处理。通过检查和调整时间事件,以避免无限期延迟并保证操作的及时性。
摘要由CSDN通过智能技术生成