boost/interprocess/detail/tmp_dir_helpers.hpp 自 1.56 起不再出现在 boost 中
boost/interprocess/detail/tmp_dir_helpers.hpp no longer present in boost since 1.56
我有一些遗留代码使用
boost::interprocess::ipcdetail::create_tmp_and_clean_old
在程序启动时重新初始化 boost::message_queue。直到 boost 1.56 这个函数位于
boost/interprocess/detail/tmp_dir_helpers.hpp
但是当我升级到 1.57 后,我意识到整个 header 就消失了......
有人能告诉我处理这个问题的正确方法吗?有没有新的function/mechanism?
显然,这里的问题是永远不要使用库中未记录的部分。这些是 而不是 API.
的一部分
在这种特殊情况下,它在文件名 (detail
) 和命名空间名称 (ipcdetail
) 中尤为明显。但这只是额外的好处:一般来说,图书馆作者不会 "required" 提供此类提示。
所以,不,没有 "new function/mechanism",事实上什至没有重大变化(因此很可能 "change" 没有在发行说明中报告)。
提升1_55实施
create_tmp_and_clean_old
做了什么?
inline void create_tmp_and_clean_old(std::string &tmp_name)
{
//First get the temp directory
std::string root_tmp_name;
get_tmp_base_dir(root_tmp_name);
//If fails, check that it's because already exists
if(!create_directory(root_tmp_name.c_str())){
error_info info(system_error_code());
if(info.get_error_code() != already_exists_error){
throw interprocess_exception(info);
}
}
#if defined(BOOST_INTERPROCESS_HAS_KERNEL_BOOTTIME)
tmp_folder(tmp_name);
//If fails, check that it's because already exists
if(!create_directory(tmp_name.c_str())){
error_info info(system_error_code());
if(info.get_error_code() != already_exists_error){
throw interprocess_exception(info);
}
}
//Now erase all old directories created in the previous boot sessions
std::string subdir = tmp_name;
subdir.erase(0, root_tmp_name.size()+1);
delete_subdirectories(root_tmp_name, subdir.c_str());
#else
tmp_name = root_tmp_name;
#endif
}
This is only internally used in Windows interprocess mechanisms (semaphore
, mutex
, mapped_region
) indirectly through *_intermodule_singleton
.
如何修复?
您可以查看 intermodule_singleton 类 的实施,了解他们如何在 1_56+ 中实现目标。
理想情况下,您可以仔细看看为什么您的程序甚至需要在此级别干扰库实现细节(提示:可能 needed/could 最好通过其他方式实现)。
看起来 create_shared_dir_and_clean_old
函数在 boost/interprocess/detail/shared_dir_helpers.hpp
中仍然存在
我有一些遗留代码使用
boost::interprocess::ipcdetail::create_tmp_and_clean_old
在程序启动时重新初始化 boost::message_queue。直到 boost 1.56 这个函数位于
boost/interprocess/detail/tmp_dir_helpers.hpp
但是当我升级到 1.57 后,我意识到整个 header 就消失了...... 有人能告诉我处理这个问题的正确方法吗?有没有新的function/mechanism?
显然,这里的问题是永远不要使用库中未记录的部分。这些是 而不是 API.
的一部分在这种特殊情况下,它在文件名 (detail
) 和命名空间名称 (ipcdetail
) 中尤为明显。但这只是额外的好处:一般来说,图书馆作者不会 "required" 提供此类提示。
所以,不,没有 "new function/mechanism",事实上什至没有重大变化(因此很可能 "change" 没有在发行说明中报告)。
提升1_55实施
create_tmp_and_clean_old
做了什么?
inline void create_tmp_and_clean_old(std::string &tmp_name)
{
//First get the temp directory
std::string root_tmp_name;
get_tmp_base_dir(root_tmp_name);
//If fails, check that it's because already exists
if(!create_directory(root_tmp_name.c_str())){
error_info info(system_error_code());
if(info.get_error_code() != already_exists_error){
throw interprocess_exception(info);
}
}
#if defined(BOOST_INTERPROCESS_HAS_KERNEL_BOOTTIME)
tmp_folder(tmp_name);
//If fails, check that it's because already exists
if(!create_directory(tmp_name.c_str())){
error_info info(system_error_code());
if(info.get_error_code() != already_exists_error){
throw interprocess_exception(info);
}
}
//Now erase all old directories created in the previous boot sessions
std::string subdir = tmp_name;
subdir.erase(0, root_tmp_name.size()+1);
delete_subdirectories(root_tmp_name, subdir.c_str());
#else
tmp_name = root_tmp_name;
#endif
}
This is only internally used in Windows interprocess mechanisms (
semaphore
,mutex
,mapped_region
) indirectly through*_intermodule_singleton
.
如何修复?
您可以查看 intermodule_singleton 类 的实施,了解他们如何在 1_56+ 中实现目标。
理想情况下,您可以仔细看看为什么您的程序甚至需要在此级别干扰库实现细节(提示:可能 needed/could 最好通过其他方式实现)。
看起来 create_shared_dir_and_clean_old
函数在 boost/interprocess/detail/shared_dir_helpers.hpp