48 lines
1.3 KiB
C++
48 lines
1.3 KiB
C++
/**
|
|
* @file mix_cc/shm/container/map.h
|
|
* @brief 共享内存的map实现
|
|
* @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 <mix_cc/shm/stl_builder.h>
|
|
#include <utility>
|
|
#include <functional>
|
|
#include <boost/interprocess/containers/map.hpp>
|
|
|
|
namespace mix_cc {
|
|
namespace shm {
|
|
/**
|
|
* @brief 共享内存Map
|
|
* @tparam Key
|
|
* @tparam T
|
|
* @tparam CompareFunc
|
|
* @tparam Segment
|
|
* @tparam Options
|
|
*/
|
|
template <class Key, class T, class CompareFunc = std::less<Key>,
|
|
class Segment = bip::managed_mapped_file, class Options = void>
|
|
using Map = typename bip::map<Key, T, CompareFunc,
|
|
ScopedShmAlloc<std::pair<const Key, T>, Segment>,
|
|
Options>;
|
|
/**
|
|
* @brief 共享内存Map的构造器
|
|
* @tparam Key
|
|
* @tparam T
|
|
* @tparam CompareFunc
|
|
* @tparam Segment
|
|
* @tparam Options
|
|
*/
|
|
template <class Key, class T, class CompareFunc = std::less<Key>,
|
|
class Segment = bip::managed_mapped_file, class Options = void>
|
|
class MapBuilder : public StlBuilder<Map<Key, T, CompareFunc, Segment, Options>,
|
|
std::pair<const Key, T>, Segment> {};
|
|
|
|
} // namespace shm
|
|
} // namespace mix_cc
|