Commit d4ebcf0e authored by Simon Spannagel's avatar Simon Spannagel
Browse files

Make user termination work with Ctrl+C

parent ac3a06ae
......@@ -16,7 +16,7 @@
using namespace corryvreckan;
// Default constructor
Analysis::Analysis(std::string config_file_name) {
Analysis::Analysis(std::string config_file_name) : m_terminate(false) {
// Load the global configuration
conf_mgr_ = std::make_unique<corryvreckan::ConfigManager>(std::move(config_file_name));
......@@ -274,6 +274,11 @@ void Analysis::run() {
// Increment event number
if(!noData)
m_events++;
// Check for user termination and stop the event loop:
if(m_terminate) {
break;
}
}
// If running the gui, don't close until the user types a command
......@@ -281,6 +286,10 @@ void Analysis::run() {
cin.ignore();
}
void Analysis::terminate() {
m_terminate = true;
}
// Initalise all algorithms
void Analysis::initialiseAll() {
int nTracks = 0;
......
......@@ -42,6 +42,7 @@ namespace corryvreckan {
void initialiseAll();
void finaliseAll();
void terminate();
void reset(){};
TBrowser* browser;
......@@ -58,6 +59,9 @@ namespace corryvreckan {
TDirectory* m_directory;
std::map<std::string, void*> loaded_libraries_;
int m_events;
private:
std::atomic<bool> m_terminate;
};
}
#endif // ANALYSIS_H
......@@ -48,7 +48,7 @@ void interrupt_handler(int) {
// Stop the framework if it is loaded
if(cv_ready) {
LOG(STATUS) << "Interrupted! Finishing up current event...";
corry->finaliseAll();
corry->terminate();
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment