#pragma once /** * @file TaskData.h * @brief task进程,缓存数据(动态vector,按需分配) * @author your name (you@domain.com) * @version 0.2 * @date 2024-02-27 * * Copyright: Baosight Co. Ltd. * DO NOT COPY/USE WITHOUT PERMISSION */ #include namespace TaskShm { namespace SHM = mix_cc::shm; namespace bipc = mix_cc::shm::bip; const static std::string dir_path = "/users/dsc/shm"; const static std::string shm_file = "TaskData"; ///<映射文件名 const double data_size = 10; ///< 数据大小 MB(按需动态) static bipc::managed_mapped_file obj_mapped_file(bipc::open_or_create, (dir_path + "/" + shm_file + "_boost.mmap").c_str(), mix_cc::data_size::MB(data_size)); typedef bipc::managed_mapped_file::segment_manager segment_manager_t; typedef bipc::node_allocator vec_allocator_f; typedef boost::container::vector shm_vector_f; struct TaskRecord { shm_vector_f data_record; TaskRecord(const bipc::node_allocator &alloc) : data_record(alloc) {} }; /*单例 map 记录task数据项*/ const static bipc::offset_ptr> TaskRecordPtr = SHM::MapBuilder::find_or_construct(&obj_mapped_file, shm_file); } // namespace TaskShm