eis/TestProject/SHM/ShmMap.h

30 lines
977 B
C
Raw Permalink Normal View History

#include <mix_cc/shm.h>
namespace EqpmShm {
namespace SHM = mix_cc::shm;
namespace bipc = mix_cc::shm::bip;
const static std::string dir_path = "/users/dsc/code/TestProject/ShmTest/build";
const static std::string shm_file = "ShmMap"; ///<映射文件名
const double data_size = 5; ///< 数据大小 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));
/**
* @brief ,
*/
struct TimeRecord {
int stime;
int etime;
double per_weight; ///<千克
double per_length; ///<米
};
/*单例 map 记录每天的重量 长度*/
const static bipc::offset_ptr<SHM::Map<int, SHM::String>> EqpmRecordPtr =
SHM::MapBuilder<int, SHM::String>::find_or_construct(&obj_mapped_file,
shm_file);
} // namespace EqpmShm