Apollo 10.0
自动驾驶开放平台
base_map_pool.h
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2019 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#pragma once
17
18#include <list>
19#include <set>
20
21#include <boost/thread.hpp>
22
23#include "Eigen/Core"
24
25#include "cyber/task/task.h"
27
28namespace apollo {
29namespace localization {
30namespace msf {
31namespace pyramid_map {
32
35 public:
40 BaseMapNodePool(unsigned int pool_size, unsigned int thread_size);
42 virtual ~BaseMapNodePool();
47 void Initial(const BaseMapConfig* map_config, bool is_fixed_size = true);
49 void Release();
57 void FreeMapNode(BaseMapNode* map_node);
59 unsigned int GetPoolSize() { return pool_size_; }
60
61 private:
65 void FreeMapNodeTask(BaseMapNode* map_node);
67 virtual BaseMapNode* AllocNewMapNode() = 0;
69 virtual void InitNewMapNode(BaseMapNode* node);
71 virtual void FinalizeMapNode(BaseMapNode* node);
73 virtual void DellocMapNode(BaseMapNode* node);
75 virtual void ResetMapNode(BaseMapNode* node);
76
77 protected:
81 std::list<BaseMapNode*> free_list_;
83 std::set<BaseMapNode*> busy_nodes_;
85 unsigned int pool_size_ = 0;
87 std::future<void> node_reset_workers_;
89 boost::mutex mutex_;
91 const BaseMapConfig* map_config_ = nullptr;
92};
93
94} // namespace pyramid_map
95} // namespace msf
96} // namespace localization
97} // namespace apollo
The memory pool for the data structure of BaseMapNode.
const BaseMapConfig * map_config_
The mutex for release thread.
BaseMapNode * AllocMapNode()
Get a MapNode object from memory pool.
std::set< BaseMapNode * > busy_nodes_
The set for used node.
boost::mutex mutex_
The mutex for release thread.
std::list< BaseMapNode * > free_list_
The list for free 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.
void Initial(const BaseMapConfig *map_config, bool is_fixed_size=true)
Initialize the pool.
unsigned int pool_size_
The size of memory pool.
The data structure of a Node in the map.
class register implement
Definition arena_queue.h:37