/** * @file mix_cc/shm/utility.h * @brief 共享内存常用工具 * @author Cat (null.null.null@qq.com) * @version 0.1 * @date 2021-05-07 * * Copyright: Baosight Co. Ltd. * DO NOT COPY/USE WITHOUT PERMISSION * */ #pragma once #include #include #include #include "mix_cc/type/data_size.h" #include "mix_cc/utility/read_config.h" #include #include #include #include #include #include #include namespace mix_cc { namespace shm { namespace bip = boost::interprocess; namespace bc = boost::container; template using ScopedShmAlloc = bc::scoped_allocator_adaptor< bip::allocator>; namespace utility { /** * @brief Get the mapped path info * @return std::string */ maybe get_mapped_path_maybe(); /** * @brief 得到映射的共享内存文件 * @param file_path 文件路径 * @param mapped_file_name 文件名 * @param size 大小 * @return bip::managed_mapped_file */ bip::managed_mapped_file get_managed_mapped_file( const std::string& file_path, const std::string& mapped_file_name, const data_size_t& size); /** * @brief 删除映射的共享内存文件 * @param file_path 文件路径 * @param file_name 文件名 * @return true * @return false */ bool remove_mapped_file(const std::string& file_path, const std::string& file_name); bip::managed_shared_memory get_managed_memory_segment( const std::string& segment_name, const data_size_t& size); }; // namespace utility } // namespace shm } // namespace mix_cc