Apollo 10.0
自动驾驶开放平台
apollo::localization::msf::BaseMapNodePool类 参考abstract

The memory pool for the data structure of BaseMapNode. 更多...

#include <base_map_pool.h>

类 apollo::localization::msf::BaseMapNodePool 继承关系图:
apollo::localization::msf::BaseMapNodePool 的协作图:

Public 成员函数

 BaseMapNodePool (unsigned int pool_size, unsigned int thread_size)
 Constructor
 
virtual ~BaseMapNodePool ()
 Destructor
 
void Initial (const BaseMapConfig *map_config, bool is_fixed_size=true)
 Initialize the pool.
 
void Release ()
 Release the pool.
 
BaseMapNodeAllocMapNode ()
 Get a MapNode object from memory pool.
 
void FreeMapNode (BaseMapNode *map_node)
 Release MapNode object to memory pool.
 
unsigned int GetPoolSize ()
 Get the size of pool.
 

Protected 属性

bool is_fixed_size_
 The flag of pool auto expand.
 
std::list< BaseMapNode * > free_list_
 The list for free node.
 
std::set< BaseMapNode * > busy_nodes_
 The set for used node.
 
unsigned int pool_size_
 The size of memory pool.
 
std::future< void > node_reset_workers_
 The thread pool for release node.
 
boost::mutex mutex_
 The mutex for release thread.
 
const BaseMapConfigmap_config_
 The mutex for release thread.
 

详细描述

The memory pool for the data structure of BaseMapNode.

在文件 base_map_pool.h32 行定义.

构造及析构函数说明

◆ BaseMapNodePool()

apollo::localization::msf::BaseMapNodePool::BaseMapNodePool ( unsigned int  pool_size,
unsigned int  thread_size 
)

Constructor

参数
<pool_size>The memory pool size.
<thread_size>The thread pool size.

在文件 base_map_pool.cc28 行定义.

30 : pool_size_(pool_size) {}
unsigned int pool_size_
The size of memory pool.

◆ ~BaseMapNodePool()

apollo::localization::msf::BaseMapNodePool::~BaseMapNodePool ( )
virtual

Destructor

在文件 base_map_pool.cc32 行定义.

32{ Release(); }

成员函数说明

◆ AllocMapNode()

BaseMapNode * apollo::localization::msf::BaseMapNodePool::AllocMapNode ( )

Get a MapNode object from memory pool.

参数
<return>The MapNode object.

在文件 base_map_pool.cc62 行定义.

62 {
63 if (free_list_.empty()) {
64 if (node_reset_workers_.valid()) {
66 }
67 }
68 boost::unique_lock<boost::mutex> lock(mutex_);
69 if (free_list_.empty()) {
70 if (is_fixed_size_) {
71 return nullptr;
72 }
73 BaseMapNode* node = AllocNewMapNode();
74 InitNewMapNode(node);
75 pool_size_++;
76 busy_nodes_.insert(node);
77 return node;
78 } else {
79 BaseMapNode* node = free_list_.front();
80 free_list_.pop_front();
81 busy_nodes_.insert(node);
82 return node;
83 }
84}
bool is_fixed_size_
The flag of pool auto expand.
std::set< BaseMapNode * > busy_nodes_
The set for used node.
std::future< void > node_reset_workers_
The thread pool for release node.
boost::mutex mutex_
The mutex for release thread.
std::list< BaseMapNode * > free_list_
The list for free node.

◆ FreeMapNode()

void apollo::localization::msf::BaseMapNodePool::FreeMapNode ( BaseMapNode map_node)

Release MapNode object to memory pool.

参数
<map_node>The released MapNode object.

在文件 base_map_pool.cc86 行定义.

86 {
88 cyber::Async(&BaseMapNodePool::FreeMapNodeTask, this, map_node);
89}

◆ GetPoolSize()

unsigned int apollo::localization::msf::BaseMapNodePool::GetPoolSize ( )
inline

Get the size of pool.

在文件 base_map_pool.h57 行定义.

57{ return pool_size_; }

◆ Initial()

void apollo::localization::msf::BaseMapNodePool::Initial ( const BaseMapConfig map_config,
bool  is_fixed_size = true 
)

Initialize the pool.

参数
<map_config>The map option.
<is_fixed_size>The flag of pool auto expand.

在文件 base_map_pool.cc34 行定义.

35 {
36 is_fixed_size_ = is_fixed_size;
37 map_config_ = map_config;
38 for (unsigned int i = 0; i < pool_size_; ++i) {
39 BaseMapNode* node = AllocNewMapNode();
40 InitNewMapNode(node);
41 free_list_.push_back(node);
42 }
43}
const BaseMapConfig * map_config_
The mutex for release thread.

◆ Release()

void apollo::localization::msf::BaseMapNodePool::Release ( )

Release the pool.

在文件 base_map_pool.cc45 行定义.

45 {
46 if (node_reset_workers_.valid()) {
48 }
49 for (BaseMapNode* node : free_list_) {
50 FinalizeMapNode(node);
51 DellocMapNode(node);
52 }
53 free_list_.clear();
54 for (BaseMapNode* node : busy_nodes_) {
55 FinalizeMapNode(node);
56 DellocMapNode(node);
57 }
58 busy_nodes_.clear();
59 pool_size_ = 0;
60}

类成员变量说明

◆ busy_nodes_

std::set<BaseMapNode*> apollo::localization::msf::BaseMapNodePool::busy_nodes_
protected

The set for used node.

在文件 base_map_pool.h81 行定义.

◆ free_list_

std::list<BaseMapNode*> apollo::localization::msf::BaseMapNodePool::free_list_
protected

The list for free node.

在文件 base_map_pool.h79 行定义.

◆ is_fixed_size_

bool apollo::localization::msf::BaseMapNodePool::is_fixed_size_
protected

The flag of pool auto expand.

在文件 base_map_pool.h77 行定义.

◆ map_config_

const BaseMapConfig* apollo::localization::msf::BaseMapNodePool::map_config_
protected

The mutex for release thread.

在文件 base_map_pool.h89 行定义.

◆ mutex_

boost::mutex apollo::localization::msf::BaseMapNodePool::mutex_
protected

The mutex for release thread.

在文件 base_map_pool.h87 行定义.

◆ node_reset_workers_

std::future<void> apollo::localization::msf::BaseMapNodePool::node_reset_workers_
protected

The thread pool for release node.

在文件 base_map_pool.h85 行定义.

◆ pool_size_

unsigned int apollo::localization::msf::BaseMapNodePool::pool_size_
protected

The size of memory pool.

在文件 base_map_pool.h83 行定义.


该类的文档由以下文件生成: