From 19235b4c6298c319f1837acf499c32b3ed41dbfb Mon Sep 17 00:00:00 2001 From: Babicaa Date: Tue, 2 Apr 2019 15:52:22 +0200 Subject: [PATCH] Add signaling from writer to manager --- lib/src/ProcessManager.cpp | 3 +++ lib/src/WriterManager.cpp | 27 ++++++--------------------- lib/src/WriterManager.hpp | 6 ++---- 3 files changed, 11 insertions(+), 25 deletions(-) diff --git a/lib/src/ProcessManager.cpp b/lib/src/ProcessManager.cpp index a67f751..f6ee605 100644 --- a/lib/src/ProcessManager.cpp +++ b/lib/src/ProcessManager.cpp @@ -297,6 +297,8 @@ void ProcessManager::write_h5 (string output_file, uint64_t n_frames) cout << "[" << std::chrono::system_clock::now() << "]"; cout << "[ProcessManager::write] Writer thread stopped." << endl; #endif + + writer_manager.writing_completed(); } void ProcessManager::write_h5_format(H5::H5File& file) { @@ -319,3 +321,4 @@ void ProcessManager::write_h5_format(H5::H5File& file) { std::cout << "[ProcessManager::write_h5_format] Error while trying to write file format: "<< ex.what() << endl; } } + diff --git a/lib/src/WriterManager.cpp b/lib/src/WriterManager.cpp index 6243b98..2af508d 100644 --- a/lib/src/WriterManager.cpp +++ b/lib/src/WriterManager.cpp @@ -130,6 +130,7 @@ void WriterManager::start(const unordered_map& new_parameter cout << output_message.str() << endl; #endif + writing_flag = true; boost::thread writer_thread(&ProcessManager::write_h5, this, "output_file", 123); } @@ -143,28 +144,9 @@ bool WriterManager::is_running() return running_flag.load(); } -bool WriterManager::is_killed() const +bool WriterManager::is_writing() const { - return killed_flag.load(); -} - -bool WriterManager::are_all_parameters_set() -{ - for (const auto& parameter : parameters_type) { - const auto& parameter_name = parameter.first; - - if (parameters.count(parameter_name) == 0) { - #ifdef DEBUG_OUTPUT - using namespace date; - cout << "[" << std::chrono::system_clock::now() << "]"; - cout << "[WriterManager::are_all_parameters_set] Parameter " << parameter_name << " not set." << endl; - #endif - - return false; - } - } - - return true; + return writing_flag.load(); } bool WriterManager::receive_frame() { @@ -183,3 +165,6 @@ bool WriterManager::write_frame() { return false; } +void WriterManager::writing_completed() { + writing_flag = false; +} diff --git a/lib/src/WriterManager.hpp b/lib/src/WriterManager.hpp index 87f2bd2..8905009 100644 --- a/lib/src/WriterManager.hpp +++ b/lib/src/WriterManager.hpp @@ -60,10 +60,8 @@ class WriterManager bool write_frame(); // True if the writing should continue. bool is_writing() const; - - bool is_killed() const; - bool are_all_parameters_set(); - std::string get_output_file() const; + // Signal that the writing has completed. + void writing_completed(); }; #endif