有关TcpConnection::handleRead中的messageCallback_的小疑问 #560
tomatowithpotato
started this conversation in
General
Replies: 1 comment
-
为了防止 stack overflow,因为 writeCompleteCallback_ 往往会再次调用 TcpConnection::send()。 如果直接调用 writeCompleteCallback_,有可能出现递归: send("a") -> sendInLoop("a") -> writeCompleteCallback_() -> send("b") -> sendInLoop("b") -> writeCompleteCallback_() -> send("c") -> sendInLoop("c") -> writeCompleteCallback_() -> ... |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
我看handleRead函数里会在判断接收到数据后,直接执行回调函数messageCallback_
但是在handleWrite中,回调函数writeCompleteCallback_是交给queueInLoop来执行的
为什么会有这种区别呢?求大佬赐教!!!!
Beta Was this translation helpful? Give feedback.
All reactions