Apollo 10.0
自动驾驶开放平台
shm_conf.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#ifndef CYBER_TRANSPORT_SHM_SHM_CONF_H_
18#define CYBER_TRANSPORT_SHM_SHM_CONF_H_
19
20#include <cstdint>
21#include <string>
22
23namespace apollo {
24namespace cyber {
25namespace transport {
26
27class ShmConf {
28 public:
29 ShmConf();
30 explicit ShmConf(const uint64_t& real_msg_size);
31 virtual ~ShmConf();
32
33 void Update(const uint64_t& real_msg_size);
34
35 const uint64_t& ceiling_msg_size() { return ceiling_msg_size_; }
36 const uint64_t& block_buf_size() { return block_buf_size_; }
37 const uint32_t& block_num() { return block_num_; }
38 const uint64_t& managed_shm_size() { return managed_shm_size_; }
39
40 // For arena msg
41 static const uint32_t ARENA_BLOCK_NUM;
42 static const uint64_t ARENA_MESSAGE_SIZE;
43
44 private:
45 uint64_t GetCeilingMessageSize(const uint64_t& real_msg_size);
46 uint64_t GetBlockBufSize(const uint64_t& ceiling_msg_size);
47 uint32_t GetBlockNum(const uint64_t& ceiling_msg_size);
48
49 uint64_t ceiling_msg_size_;
50 uint64_t block_buf_size_;
51 uint32_t block_num_;
52 uint64_t managed_shm_size_;
53
54 // Extra size, Byte
55 static const uint64_t EXTRA_SIZE;
56 // State size, Byte
57 static const uint64_t STATE_SIZE;
58 // Block size, Byte
59 static const uint64_t BLOCK_SIZE;
60 // Message info size, Byte
61 static const uint64_t MESSAGE_INFO_SIZE;
62 // For message 0-10K
63 static const uint32_t BLOCK_NUM_16K;
64 static const uint64_t MESSAGE_SIZE_16K;
65 // For message 10K-100K
66 static const uint32_t BLOCK_NUM_128K;
67 static const uint64_t MESSAGE_SIZE_128K;
68 // For message 100K-1M
69 static const uint32_t BLOCK_NUM_1M;
70 static const uint64_t MESSAGE_SIZE_1M;
71 // For message 1M-6M
72 static const uint32_t BLOCK_NUM_8M;
73 static const uint64_t MESSAGE_SIZE_8M;
74 // For message 6M-10M
75 static const uint32_t BLOCK_NUM_16M;
76 static const uint64_t MESSAGE_SIZE_16M;
77 // For message 10M+
78 static const uint32_t BLOCK_NUM_MORE;
79 static const uint64_t MESSAGE_SIZE_MORE;
80};
81
82} // namespace transport
83} // namespace cyber
84} // namespace apollo
85
86#endif // CYBER_TRANSPORT_SHM_SHM_CONF_H_
static const uint32_t ARENA_BLOCK_NUM
Definition shm_conf.h:41
const uint64_t & ceiling_msg_size()
Definition shm_conf.h:35
const uint64_t & managed_shm_size()
Definition shm_conf.h:38
const uint32_t & block_num()
Definition shm_conf.h:37
static const uint64_t ARENA_MESSAGE_SIZE
Definition shm_conf.h:42
void Update(const uint64_t &real_msg_size)
Definition shm_conf.cc:30
const uint64_t & block_buf_size()
Definition shm_conf.h:36
class register implement
Definition arena_queue.h:37