We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Describe the bug
AsyncWrite接受一个callback, 看上去可以用来做这次AsyncWrite完成的通知。
但其实,需要写出去的数据在callback完成时可能还被buffer在内存里。
考虑流式写数据的场景,会循环调AsyncWrite,然后等AsyncWrite完成,伪代码如下
for { buf := make([]byte, 1024) reader.Read(buf) AsyncWrite(buf, callback) // 此时希望等待buf被全部写出去,然后再读下一块数据 }
如果往外写数据比较慢,就会导致内存一直增长, 需要有一种手段等待buf写真正完成
The text was updated successfully, but these errors were encountered:
可以调用 Conn.Flush(),不过这个只能在 OnTraffic()/OnClose() 这些回调函数里调用,因为不是线程安全的。
Conn.Flush()
Sorry, something went wrong.
callback 为什么不把写错误也搞出来 ,func(cc gnet.Conn,err error) error像这样。
func(cc gnet.Conn,err error) error
panjf2000
No branches or pull requests
Describe the bug
AsyncWrite接受一个callback, 看上去可以用来做这次AsyncWrite完成的通知。
但其实,需要写出去的数据在callback完成时可能还被buffer在内存里。
考虑流式写数据的场景,会循环调AsyncWrite,然后等AsyncWrite完成,伪代码如下
如果往外写数据比较慢,就会导致内存一直增长, 需要有一种手段等待buf写真正完成
The text was updated successfully, but these errors were encountered: