- 论坛徽章:
- 0
|
eventfd = pipe();
mutex_lock: lock;
socket_list: list;
keepalive_routine:
{
set timeout = check_interval
set notify = false;
getlock;
set notify = true if exists timeout socket in socket_list;
update timeout;
unlock;
if notify
wakup_epoll;
wait_timeout(timeout);
}
wakup_epoll:
{
write 1 bytes to eventfd, this will force epoll_wait return.
}
epoll_routine:
{
add eventfd to epoll
again:
if (eventfd is readable)
read all bytes in eventfd
getlock;
remove and close timeout socket;
unlock;
epoll_wait;
goto again;
}
[ 本帖最后由 pagx 于 2009-12-14 22:49 编辑 ] |
|