Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

O(1)复杂度的心跳机制检测询问 #20

Closed
szza opened this issue Jun 11, 2020 · 1 comment
Closed

O(1)复杂度的心跳机制检测询问 #20

szza opened this issue Jun 11, 2020 · 1 comment

Comments

@szza
Copy link

szza commented Jun 11, 2020

这段代码是什么语义呢,为什么每定时器触发一次就清空一次连接对象呢

void TimerWheel::wheelCallback()
{
    if(!timeoutSec_)
        return;
    if(++index_ ==timeoutSec_)
    {
        index_=0;
    }
    wheel[index_].clear();
}
@wlgq2
Copy link
Owner

wlgq2 commented Jun 11, 2020

设置心跳超时秒数时间内,如果服务端没有收到客户端发送的消息,则主动断开客户端连接。这里是利用RAII在析构函数里面做断开连接操作。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants