Skip to content

Commit

Permalink
Make reader thread-local to ensure thread-safety
Browse files Browse the repository at this point in the history
  • Loading branch information
EricMEsch committed Sep 3, 2024
1 parent 7a1a7c9 commit e5e983d
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 4 deletions.
4 changes: 2 additions & 2 deletions include/RMGGrabmayrGCReader.hh
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ struct GammaCascadeLine {
class RMGGrabmayrGCReader {
public:

static RMGGrabmayrGCReader* GetInstance();
static G4ThreadLocal RMGGrabmayrGCReader* GetInstance();
~RMGGrabmayrGCReader();
// RMGGrabmayrGCReader& operator=(const RMGGrabmayrGCReader&) = delete;

Expand All @@ -49,7 +49,7 @@ class RMGGrabmayrGCReader {

private:

static RMGGrabmayrGCReader* instance;
static G4ThreadLocal RMGGrabmayrGCReader* instance;
RMGGrabmayrGCReader();
// std::vector<std::unique_ptr<std::ifstream>> files;
// map holding the corresponding file for each isotope
Expand Down
2 changes: 1 addition & 1 deletion src/RMGGrabmayrGCReader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include "RMGLog.hh"


RMGGrabmayrGCReader* RMGGrabmayrGCReader::instance = nullptr;
G4ThreadLocal RMGGrabmayrGCReader* RMGGrabmayrGCReader::instance = nullptr;

RMGGrabmayrGCReader* RMGGrabmayrGCReader::GetInstance() {
if (instance == nullptr) { instance = new RMGGrabmayrGCReader(); }
Expand Down
1 change: 0 additions & 1 deletion src/RMGUserAction.cc
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ void RMGUserAction::Build() const {
this->SetUserAction(new RMGStackingAction(run_action));
this->SetUserAction(stepping_action);
this->SetUserAction(tracking_action);
// Maybe add a check for multithreaded and only do this if not?
RMGGrabmayrGCReader::GetInstance();
}

Expand Down

0 comments on commit e5e983d

Please sign in to comment.