From 5fb06c763008ab75b03e606b6e8b6aa6f5cf4eff Mon Sep 17 00:00:00 2001 From: meschi <emilio.meschi@cern.ch> Date: Wed, 26 Oct 2022 12:58:18 +0200 Subject: [PATCH] various fixes in the file handler thread --- src/OutputFileHandler.h | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/OutputFileHandler.h b/src/OutputFileHandler.h index 1981f111..68f0449f 100644 --- a/src/OutputFileHandler.h +++ b/src/OutputFileHandler.h @@ -11,13 +11,13 @@ class OutputFileHandler { public: - OutputFileHandler(const std::string base_path, - const std::string filename_prefix) + OutputFileHandler(const std::string &base_path, + const std::string &filename_prefix) : base_path_(base_path), filename_prefix_(filename_prefix), working_files_base_path_(base_path_ + "/" + working_dir_), current_run_number_(0), current_index_(0), current_filename_(""), - current_file_(0), close_and_rename_(base_path), - t(std::thread(close_and_rename_)) { + current_file_(0), close_and_rename_(base_path_), t{} { + t = std::thread(close_and_rename_); create_output_directory_maybe(working_files_base_path_); } @@ -30,6 +30,8 @@ public: FILE *getFile(uint32_t run, uint32_t index); + bool hasFile() { return current_file_ != 0; } + private: void create_output_directory_maybe(std::string &output_directory); @@ -44,7 +46,7 @@ private: class close_and_rename { public: - close_and_rename(std::string base_path) : base_path_(base_path) {} + close_and_rename(std::string &base_path) : base_path_(base_path) {} void operator()() const; -- GitLab