Apollo 10.0
自动驾驶开放平台
block_manager.cc
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2023 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
18
20
21namespace apollo {
22namespace cyber {
23namespace profiler {
24
25thread_local std::unordered_map<std::string, Frame>
26 BlockManager::routine_frame_map_{};
27
28BlockManager::BlockManager() {}
29
31 Frame* frame_ptr = GetRoutineFrame();
32 if (frame_ptr == nullptr || block == nullptr)
33 return;
34 frame_ptr->Push(block);
35 block->set_depth(frame_ptr->size());
36 block->Start();
37}
38
40 Frame* frame_ptr = GetRoutineFrame();
41 if (frame_ptr == nullptr || frame_ptr->finished())
42 return;
43
44 Block* block = frame_ptr->Top();
45 block->End();
46 frame_ptr->Pop();
47
48 if (frame_ptr->finished()) {
49 const std::string& routine_name = GetRoutineName();
50 frame_ptr->DumpToFile(routine_name);
51 frame_ptr->Clear();
52 }
53}
54
55std::string BlockManager::GetRoutineName() {
56 std::string routine_name("default_croutine");
59 }
60 return routine_name;
61}
62
63Frame* BlockManager::GetRoutineFrame() {
64 const std::string& routine_name = GetRoutineName();
65 return &routine_frame_map_[routine_name];
66}
67
68} // namespace profiler
69} // namespace cyber
70} // namespace apollo
static CRoutine * GetCurrentRoutine()
Definition croutine.h:135
const std::string & name() const
Definition croutine.h:166
void set_depth(std::uint32_t depth)
Definition block.h:41
std::uint32_t size() const
Definition frame.h:39
void Push(Block *block)
Definition frame.cc:29
bool DumpToFile(const std::string &coroutine_name)
Definition frame.cc:49
class register implement
Definition arena_queue.h:37