eis/shm/TaskData.h

42 lines
1.4 KiB
C
Raw Normal View History

#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 <mix_cc/shm.h>
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<float, segment_manager_t> vec_allocator_f;
typedef boost::container::vector<float, vec_allocator_f> shm_vector_f;
struct TaskRecord {
shm_vector_f data_record;
TaskRecord(const bipc::node_allocator<void, segment_manager_t> &alloc)
: data_record(alloc) {}
};
/*单例 map 记录task数据项*/
const static bipc::offset_ptr<SHM::Map<int, TaskRecord>> TaskRecordPtr =
SHM::MapBuilder<int, TaskRecord>::find_or_construct(&obj_mapped_file,
shm_file);
} // namespace TaskShm