Introduction
In the previous blog, we mentioned that the underlying Linux epoll is used in redis event processing, and other multi-channel communication layers can be used according to the implementation of redis, however, epoll is the most commonly used in Linux servers. Redis does not directly use Linux epoll but encapsulates it.
Source code
AE _epoll.c
Analysis
It is encapsulated on the basis of the original Linux epoll and mainly encapsulates several functions:
Aeapicreate: Call epoll_create to create the epoll handle and assign the epoll event.
Aeapifree: call close to close the epoll handle created by epoll_create and release the epoll event.
Aeapiaddevent: Call epoll_ctl to add an event to aeeventloop.
Aeapidelevent: Call epoll_ctl to delete an event from aeeventloop.
Aeapipoll: calls the epoll_wait wait event.
For more information about epoll, see blog: Click to open the link.