73#ifndef G4MULTITHREADED
75 msg <<
"Geant4 code is compiled without multi-threading support "
78 msg <<
" This type of RunManager can only be used in mult-threaded "
99using WorkerRunManPtr_t = std::unique_ptr<G4WorkerTaskRunManager>;
100using WorkerThreadPtr_t = std::unique_ptr<G4WorkerThread>;
102WorkerRunManPtr_t& workerRM()
108WorkerThreadPtr_t& context()
120 return context().get();
127 if (context() && workerRM())
return;
149 context() = std::make_unique<G4WorkerThread>();
159 G4int thisID = context()->GetThreadId();
187 context()->BuildGeometryAndPhysicsVector();
190 auto& wrm = workerRM();
191 wrm->SetWorkerThread(context().get());
210 workerRM()->Initialize();
233 auto& wrm = workerRM();
234 assert(wrm.get() !=
nullptr);
253 auto& wrm = workerRM();
254 assert(wrm.get() !=
nullptr);
278 if (wrm ==
nullptr)
return;
288 if (wrm ==
nullptr)
return;
320 for (
G4int i = 0; i < nCh; i++) {
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription
G4VDecayChannel * GetDecayChannel(G4int index) const
G4int GetPinAffinity() const
const CLHEP::HepRandomEngine * getMasterRandomEngine() const
static G4ThreadId GetMasterThreadId()
void reset(G4bool ifSkipIon=true)
G4PTblDicIterator * GetIterator() const
static G4ParticleTable * GetParticleTable()
virtual void SetupShadowProcess() const
const G4UserWorkerInitialization * GetUserWorkerInitialization() const
const G4VUserDetectorConstruction * GetUserDetectorConstruction() const
const G4VUserActionInitialization * GetUserActionInitialization() const
G4VUserActionInitialization * GetNonConstUserActionInitialization() const
const G4VUserPhysicsList * GetUserPhysicsList() const
const G4UserWorkerThreadInitialization * GetUserWorkerThreadInitialization() const
void SetupShadowProcess() const override
void BroadcastAbortRun(G4bool softAbort)
static void ExecuteWorkerTask()
static void InitializeWorker()
static void TerminateWorker()
static G4RUN_DLL std::vector< G4String > initCmdStack
static void TerminateWorkerRunEventLoop()
static G4WorkerThread * GetWorkerThread()
static void ExecuteWorkerInit()
void SetUpDecayChannels()
static std::vector< G4String > & InitCommandStack()
static G4TaskRunManager * GetMasterRunManager()
void SetUpForAThread(G4int tId)
G4int ApplyCommand(const char *aCommand)
static G4UImanager * GetUIpointer()
virtual void WorkerStop() const
virtual void WorkerStart() const
virtual void WorkerInitialize() const
virtual void SetupRNGEngine(const CLHEP::HepRandomEngine *aRNGEngine) const
virtual G4WorkerRunManager * CreateWorkerRunManager() const
G4ParticleDefinition * GetDaughter(G4int anIndex)
static void SetInstance(G4VSteppingVerbose *Instance)
virtual G4VSteppingVerbose * InitializeSteppingVerbose() const
virtual void Build() const =0
void RunTermination() override
void TerminateEventLoop() override
G4WorkerThread * GetWorkerThread() const
static void DestroyGeometryAndPhysicsVector()
std::shared_ptr< PackagedTask< RetT, Args... > > async(FuncT &&func, Args &&... args)
TaskManager * GetTaskManager() const
ThreadPool * GetThreadPool() const
static uintmax_t get_this_thread_id()
G4int WorkerThreadJoinsPool()
G4int WorkerThreadLeavesPool()
void SetMultithreadedApplication(G4bool value)
void G4SetThreadId(G4int aNewValue)
void G4ConsumeParameters(_Args &&...)
#define G4ThreadLocalStatic