Apollo  6.0
Open source self driving car software
shm_conf.h
Go to the documentation of this file.
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 
23 namespace apollo {
24 namespace cyber {
25 namespace transport {
26 
27 class 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  private:
41  uint64_t GetCeilingMessageSize(const uint64_t& real_msg_size);
42  uint64_t GetBlockBufSize(const uint64_t& ceiling_msg_size);
43  uint32_t GetBlockNum(const uint64_t& ceiling_msg_size);
44 
45  uint64_t ceiling_msg_size_;
46  uint64_t block_buf_size_;
47  uint32_t block_num_;
48  uint64_t managed_shm_size_;
49 
50  // Extra size, Byte
51  static const uint64_t EXTRA_SIZE;
52  // State size, Byte
53  static const uint64_t STATE_SIZE;
54  // Block size, Byte
55  static const uint64_t BLOCK_SIZE;
56  // Message info size, Byte
57  static const uint64_t MESSAGE_INFO_SIZE;
58  // For message 0-10K
59  static const uint32_t BLOCK_NUM_16K;
60  static const uint64_t MESSAGE_SIZE_16K;
61  // For message 10K-100K
62  static const uint32_t BLOCK_NUM_128K;
63  static const uint64_t MESSAGE_SIZE_128K;
64  // For message 100K-1M
65  static const uint32_t BLOCK_NUM_1M;
66  static const uint64_t MESSAGE_SIZE_1M;
67  // For message 1M-6M
68  static const uint32_t BLOCK_NUM_8M;
69  static const uint64_t MESSAGE_SIZE_8M;
70  // For message 6M-10M
71  static const uint32_t BLOCK_NUM_16M;
72  static const uint64_t MESSAGE_SIZE_16M;
73  // For message 10M+
74  static const uint32_t BLOCK_NUM_MORE;
75  static const uint64_t MESSAGE_SIZE_MORE;
76 };
77 
78 } // namespace transport
79 } // namespace cyber
80 } // namespace apollo
81 
82 #endif // CYBER_TRANSPORT_SHM_SHM_CONF_H_
void Update(const uint64_t &real_msg_size)
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
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
Definition: shm_conf.h:27
const uint64_t & block_buf_size()
Definition: shm_conf.h:36