Add signaling from writer to manager

This commit is contained in:
2019-04-02 15:52:22 +02:00
parent 1c3304861e
commit 19235b4c62
3 changed files with 11 additions and 25 deletions
+3
View File
@@ -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;
}
}
+6 -21
View File
@@ -130,6 +130,7 @@ void WriterManager::start(const unordered_map<string, boost::any>& 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;
}
+2 -4
View File
@@ -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