Allenxuxu / gev

🚀Gev is a lightweight, fast non-blocking TCP network library / websocket server based on Reactor mode. Support custom protocols to quickly and easily build high-performance servers.
MIT License
1.72k stars 193 forks source link

这里为什么是一个循环啊??? #117

Closed ghost closed 2 years ago

ghost commented 2 years ago

https://github.com/Allenxuxu/gev/blob/9262fa12b35a46747cf40ee5cd43efa9187adf85/connection.go#L208

Allenxuxu commented 2 years ago

尽可能的把内存中所有数据处理完

ghost commented 2 years ago

可是我看了与之相关的代码,c.protocol.UnPacket(c, buffer)中的buffer要么是c.buffer,要么是c.inBuffer,只有handleRead调用了handleProtocol,handleRead的过程中,没有其他协程使用c.bufferc.inBuffer,所以说只需要一次c.protocol.UnPacket(c, buffer),无须循环呀!我还是不太明白