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.73k stars 194 forks source link

这里的循环是不是换成if也行 #121

Closed ghost closed 2 years ago

ghost commented 2 years ago

https://github.com/Allenxuxu/gev/blob/9262fa12b35a46747cf40ee5cd43efa9187adf85/connection.go#L208 c.protocol.UnPacket(c, buffer)中的buffer要么是c.buffer,要么是c.inBuffer,只有handleRead调用了handleProtocol,handleRead的过程中,没有其他协程使用c.buffer和c.inBuffer,所以说只需要一次c.protocol.UnPacket(c, buffer),无须循环呀!我还是不太明白

Allenxuxu commented 2 years ago

是的,但是我想将读到的数据尽快解析出来

ghost commented 2 years ago

恩恩,晓得了