boost的“ windows_shared_memory”和boost的“ managed_windows_shared_memory”有什么区别?

时间:2019-10-24 14:57:10

标签: c++ boost shared-memory boost-interprocess

Boost提供了几种类型的共享内存。其中windows_shared_memory使用Windows自己的基础共享内存功能,因此是平台特定的,并且与其他共享内存(与POSIX兼容的共享内存)相比具有某些特殊性。

描述为here in the documentation

但是,在this other documentation page中描述了managed_windows_shared_memory。都没有提到对方的存在。

这两种共享内存实现之间有什么区别?

在我看来,根据文档,它们都有相同的行为。它们只是显示两个不同接口来使用它们的相同机制吗?

其中包含两个实现:

// The first implementation has to be included here
#include <boost/interprocess/windows_shared_memory.hpp>

// The second implantation has to be included here
#include <boost/interprocess/managed_windows_shared_memory.hpp>

1 个答案:

答案 0 :(得分:1)

boost中的“托管”一词区分了几个类接口家族,而不仅仅是 windows 共享内存。非“托管”版本更为直接和最小化,仅提供低级别操作所需的内容。 “托管”版本通常建立在非“托管”版本之上,但是还包括更多的boost模板魔术,以提供更安全,更高级的界面。通常更喜欢“托管”版本,因为它们可以为您做更多的事情。