Apollo 11.0
自动驾驶开放平台
base_map_pool.h
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2018 The Apollo Authors. All Rights Reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *****************************************************************************/
16
17#pragma once
18
19#include <list>
20#include <set>
21
22#include <boost/thread.hpp>
23
24#include "cyber/task/task.h"
26
27namespace apollo {
28namespace localization {
29namespace msf {
30
33 public:
38 BaseMapNodePool(unsigned int pool_size, unsigned int thread_size);
40 virtual ~BaseMapNodePool();
45 void Initial(const BaseMapConfig* map_config, bool is_fixed_size = true);
47 void Release();
55 void FreeMapNode(BaseMapNode* map_node);
57 unsigned int GetPoolSize() { return pool_size_; }
58
59 private:
63 void FreeMapNodeTask(BaseMapNode* map_node);
65 virtual BaseMapNode* AllocNewMapNode() = 0;
67 void InitNewMapNode(BaseMapNode* node);
69 void FinalizeMapNode(BaseMapNode* node);
71 void DellocMapNode(BaseMapNode* node);
73 void ResetMapNode(BaseMapNode* node);
74
75 protected:
79 std::list<BaseMapNode*> free_list_;
81 std::set<BaseMapNode*> busy_nodes_;
83 unsigned int pool_size_;
85 std::future<void> node_reset_workers_;
87 boost::mutex mutex_;
90};
91
92} // namespace msf
93} // namespace localization
94} // namespace apollo
The options of the reflectance map.
The memory pool for the data structure of BaseMapNode.
BaseMapNode * AllocMapNode()
Get a MapNode object from memory pool.
bool is_fixed_size_
The flag of pool auto expand.
unsigned int pool_size_
The size of memory pool.
const BaseMapConfig * map_config_
The mutex for release thread.
std::set< BaseMapNode * > busy_nodes_
The set for used node.
unsigned int GetPoolSize()
Get the size of pool.
std::future< void > node_reset_workers_
The thread pool for release node.
void FreeMapNode(BaseMapNode *map_node)
Release MapNode object to memory pool.
boost::mutex mutex_
The mutex for release thread.
void Initial(const BaseMapConfig *map_config, bool is_fixed_size=true)
Initialize the pool.
std::list< BaseMapNode * > free_list_
The list for free node.
The data structure of a Node in the map.
class register implement
Definition arena_queue.h:37