Apollo 10.0
自动驾驶开放平台
recurrent_runner.cc
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2017 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
19#include "cyber/common/log.h"
20
21namespace apollo {
22namespace monitor {
23
24RecurrentRunner::RecurrentRunner(const std::string &name, const double interval)
25 : name_(name), interval_(interval) {}
26
27void RecurrentRunner::Tick(const double current_time) {
28 if (name_ == "ProcessMonitor" &&
29 MonitorManager::Instance()->GetStatus()->detect_immediately()) {
30 RunOnce(current_time);
31 } else if (next_round_ <= current_time) {
33 AINFO_EVERY(100) << name_ << " is running round #" << round_count_;
34 next_round_ = current_time + interval_;
35 RunOnce(current_time);
36 }
37}
38
39} // namespace monitor
40} // namespace apollo
void Tick(const double current_time)
RecurrentRunner(const std::string &name, const double interval)
virtual void RunOnce(const double current_time)=0
#define AINFO_EVERY(freq)
Definition log.h:82
class register implement
Definition arena_queue.h:37