提交 87127ff3 编写于 作者: L liufeng 提交者: Liu Jiaming

Revert "cyber_recorder close file asynchronously"

This reverts commit a98591bd.
上级 0b2b2527
......@@ -16,11 +16,8 @@
#include "cyber/record/record_writer.h"
#include <chrono>
#include <future>
#include <iomanip>
#include <iostream>
#include <utility>
#include "cyber/common/log.h"
......@@ -144,11 +141,8 @@ bool RecordWriter::WriteMessage(const SingleMessage& message) {
message.time() - segment_begin_time_ > header_.segment_interval()) ||
(header_.segment_raw_size() > 0 &&
segment_raw_size_ > header_.segment_raw_size())) {
ACHECK(old_file_writer_closer_.wait_for(std::chrono::milliseconds(0)) ==
std::future_status::ready);
// Close the file via the destructor asynchronously
old_file_writer_closer_ = std::async(
std::launch::async, [](FileWriterPtr p) {}, std::move(file_writer_));
file_writer_backup_.swap(file_writer_);
file_writer_backup_->Close();
if (!SplitOutfile()) {
AERROR << "Split out file is failed.";
return false;
......
......@@ -18,7 +18,6 @@
#define CYBER_RECORD_RECORD_WRITER_H_
#include <cstdint>
#include <future>
#include <memory>
#include <mutex>
#include <set>
......@@ -186,9 +185,7 @@ class RecordWriter : public RecordBase {
MessageTypeMap channel_message_type_map_;
MessageProtoDescMap channel_proto_desc_map_;
FileWriterPtr file_writer_ = nullptr;
// Initialize with a dummy value to simplify checking later
std::future<void> old_file_writer_closer_ =
std::async(std::launch::async, []() {});
FileWriterPtr file_writer_backup_ = nullptr;
std::mutex mutex_;
std::stringstream sstream_;
};
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册