Skip to content

Commit

Permalink
made periodic print thread unique_ptr
Browse files Browse the repository at this point in the history
  • Loading branch information
lobis committed Sep 12, 2022
1 parent ed9b0b4 commit 19223f3
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
2 changes: 1 addition & 1 deletion include/SimulationManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class SimulationManager {
void WriteEvents();
void WriteEventsAndCloseFile();

std::thread* fPeriodicPrintThread = nullptr;
std::unique_ptr<std::thread> fPeriodicPrintThread = nullptr;
bool fPeriodicPrintThreadEndFlag = false;

public:
Expand Down
3 changes: 1 addition & 2 deletions src/SimulationManager.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ void SimulationManager::BeginOfRunAction() {
// gives segfault in old Geant4 versions such as 10.4.3, didn't look into it
if (GetRestMetadata()->PrintProgress() ||
GetRestMetadata()->GetVerboseLevel() >= TRestStringOutput::REST_Verbose_Level::REST_Essential) {
fPeriodicPrintThread = new thread(&PeriodicPrint, this);
fPeriodicPrintThread = make_unique<thread>(&PeriodicPrint, this);
}
#endif
}
Expand All @@ -78,7 +78,6 @@ void SimulationManager::EndOfRunAction() {
if (fPeriodicPrintThread->joinable()) {
fPeriodicPrintThread->join(); // need to join thread, it may block for up to 1 thread period
}
delete fPeriodicPrintThread;
}

for (auto& outputManager : fOutputManagerContainer) {
Expand Down

0 comments on commit 19223f3

Please sign in to comment.