Apollo 10.0
自动驾驶开放平台
play_task.cc
浏览该文件的文档.
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
18
19#include "cyber/common/log.h"
20
21namespace apollo {
22namespace cyber {
23namespace record {
24
25std::atomic<uint64_t> PlayTask::played_msg_num_ = {0};
26
27PlayTask::PlayTask(const MessagePtr& msg, const WriterPtr& writer,
28 uint64_t msg_real_time_ns, uint64_t msg_play_time_ns)
29 : msg_(msg),
30 writer_(writer),
31 msg_real_time_ns_(msg_real_time_ns),
32 msg_play_time_ns_(msg_play_time_ns) {}
33
35 if (writer_ == nullptr) {
36 AERROR << "writer is nullptr, can't write message.";
37 return;
38 }
39
40 if (!writer_->Write(msg_)) {
41 AERROR << "write message failed, played num: " << played_msg_num_.load()
42 << ", real time: " << msg_real_time_ns_
43 << ", play time: " << msg_play_time_ns_;
44 return;
45 }
46
47 played_msg_num_.fetch_add(1);
48
49 ADEBUG << "write message succ, played num: " << played_msg_num_.load()
50 << ", real time: " << msg_real_time_ns_
51 << ", play time: " << msg_play_time_ns_;
52}
53
54} // namespace record
55} // namespace cyber
56} // namespace apollo
std::shared_ptr< Writer< message::RawMessage > > WriterPtr
Definition play_task.h:34
std::shared_ptr< message::RawMessage > MessagePtr
Definition play_task.h:33
PlayTask(const MessagePtr &msg, const WriterPtr &writer, uint64_t msg_real_time_ns, uint64_t msg_play_time_ns)
Definition play_task.cc:27
#define ADEBUG
Definition log.h:41
#define AERROR
Definition log.h:44
class register implement
Definition arena_queue.h:37