使用 Boost 在共享内存中创建循环缓冲区时出现问题
我正在尝试使用 Boost circular_buffer 和 Interprocess 库在共享内存中创建循环缓冲区。我编译并运行了 进程间文档,用于在共享内存中毫无问题地创建向量。但是,当我修改它以使用 Boostcircular_buffer 时:
int main(int argc, char *argv[])
{
managed_shared_memory segment(create_only, "MySharedMemory", 65536);
const ShmemAllocator alloc_inst (segment.get_segment_manager());
MyCircBuffer *myCircBuf = segment.construct<MyCircBuffer>("MyCircBuffer")(alloc_inst);
return 0;
}
我收到编译错误(由 segment.construct()
引起)。知道我做错了什么吗?是否因为circular_buffer
不是/boost/interprocess/containers
中列出的容器之一,即它与Interprocess不兼容?
谢谢,
C
I am trying to create a circular buffer in shared memory using Boost circular_buffer
and Interprocess libraries. I compiled and ran the the example given in the Interprocess documentation for creating a vector in shared memory with no problem. However, when I modify it to use the Boost circular_buffer as:
int main(int argc, char *argv[])
{
managed_shared_memory segment(create_only, "MySharedMemory", 65536);
const ShmemAllocator alloc_inst (segment.get_segment_manager());
MyCircBuffer *myCircBuf = segment.construct<MyCircBuffer>("MyCircBuffer")(alloc_inst);
return 0;
}
I get a compilation error (caused by segment.construct()
). Any idea what I am doing wrong? Is it because circular_buffer
is not one of the containers listed in /boost/interprocess/containers
, i.e. it's not compatible with Interprocess?
Thanks,
C
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我在 boost 用户论坛上问了同样的问题,建议的解决方案是使用 -DBOOST_CB_DISABLE_DEBUG 或 -DNDEBUG 标志,因为 circular_buffer 依赖于原始指针来进行调试支持。
还有其他建议吗?
I asked the same question on the boost user forum and the solution that was suggested was to use -DBOOST_CB_DISABLE_DEBUG or -DNDEBUG flags, since
circular_buffer
relies on raw pointers for debug support.Any other suggestions?