c++ - 检查 Boost Interprocess managed_shared_memory 是否已经存在?

标签 c++ boost boost-interprocess

<分区>

有没有办法(除了 try-catch)来确定具有特定名称的 boost::interprocess:managed_shared_memory 区域是否已经存在?

我知道如果我在 managed_shared_memory 区域内分配进程间 vector ,我可以使用 managed_shared_memory::find() 检查它是否存在,但似乎没有办法检查 managed_shared_memory 区域本身是否存在。

最佳答案

您可以将构造函数与 boost::interprocess::open_or_create 一起使用。

如果你想知道两者中的哪一个发生了,你可以使用 boost::interprocess::open_onlyboost::interprocess::create_only 但你会在顶部添加“外部”同步:c++ Synchronize shared memory when reading

关于c++ - 检查 Boost Interprocess managed_shared_memory 是否已经存在?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50114321/

相关文章:

C++ 头文件链接器错误

c++ - 为什么 Rcpp::Function 可以用作 boost::function,并且可以在运行时自省(introspection)?

c++ - 访问者接口(interface)的私有(private)继承如何允许可访问对象访问访问私有(private)访问实现?

c++ - 使用 OpenSSL 编译时的 qtum-core 构建问题

C++:尝试遍历 boost::unordered_map<string,int> 时,operator< 不匹配

c++ - managed_mapped_file 是否能够因分配而增加文件大小?

c++ - 使用 boost 线程和循环缓冲区挂起的生产者/消费者

c++ - 具有常量表达式 : error C2975 with VC++2008 的模板

c++ - 两个程序之间的消息传递

c++ - 提升.MultiIndex : Are there way to share object between two processes?