如何使用 boost::asio::async_read_until 并将外部内存地址作为缓冲区
async_read_until
需要一个 basic_streambuf
来读取数据。我不想分配额外的内存,而是使用内存地址(来自不允许更改的指定接口)作为目标缓冲区。
是否可以使用外部内存地址创建一个streambuf
,或者我是否需要编写一个包装类?
async_read_until
expects a basic_streambuf
into which the data will be read. I don't want to allocate additional memory, but using a memory address (from a specified interface that I'm not allowed to change) as the target buffer.
Is it possible to create a streambuf
with an external memory address or do I need to write a wrapper-class?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
最后通过编写我自己的
async_read_until_delim
类解决了这个问题,该类需要内存指针和要读取的最大字节值。它尽可能接近原始的 boost 实现,但进行了一些调整,这应该会带来更高的执行性能。所以,我希望它对某人也有用。
Finally solved the issue by writing my own
async_read_until_delim
class which expects a memory-pointer and a maximum value of bytes to read. It's as close as possible to the original boost implementation, but has a few adjustments which should lead to a more performant execution.So, I hope it will be usefull for someone too.