Geant4 VMC Version 6.6
Loading...
Searching...
No Matches
TG4WorkerInitialization.cxx
Go to the documentation of this file.
1//------------------------------------------------
2// The Geant4 Virtual Monte Carlo package
3// Copyright (C) 2014 Ivana Hrivnacova
4// All rights reserved.
5//
6// For the licensing terms see geant4_vmc/LICENSE.
7// Contact: root-vmc@cern.ch
8//-------------------------------------------------
9
14
16#include "TG4RunManager.h"
17
18#include <RVersion.h>
19#include <TVirtualMCApplication.h>
20
21#include <G4AutoLock.hh>
22#include <G4Threading.hh>
23#include <G4Types.hh>
24
25#ifdef G4MULTITHREADED
26namespace
27{
28// Mutex to lock MCApplication::FinishRun
29G4Mutex finishRunMutex = G4MUTEX_INITIALIZER;
30// Mutex to lock deleting MC application
31// G4Mutex deleteMutex = G4MUTEX_INITIALIZER;
32// Mutex to lock FinishRun & deleting MC application
33G4Mutex stopWorkerMutex = G4MUTEX_INITIALIZER;
34} // namespace
35#endif
36
37//_____________________________________________________________________________
43
44//_____________________________________________________________________________
49
50//
51// public methods
52//
53
54//_____________________________________________________________________________
56{
58
59 // G4cout << "TG4WorkerInitialization::WorkerRunStart() " << G4endl;
60
62#ifdef G4MULTITHREADED
63 TVirtualMCApplication::Instance()->BeginRunOnWorker();
64 // G4cout << "TG4WorkerInitialization::WorkerRunStart() end " << G4endl;
65#endif
66}
67
68//_____________________________________________________________________________
70{
71 // This method is called for each thread, when the local event loop has
72 // finished but before the synchronization over threads.
73
74 // G4cout << "TG4WorkerInitialization::WorkerRunEnd() " << G4endl;
75
76#ifdef G4MULTITHREADED
77 G4AutoLock lm(&finishRunMutex);
78 TVirtualMCApplication::Instance()->FinishRunOnWorker();
79 lm.unlock();
80#endif
81
82 // G4cout << "TG4WorkerInitialization::WorkerRunEnd() end " << G4endl;
83}
84
85//_____________________________________________________________________________
87{
91
92 // G4cout << "TG4WorkerInitialization::WorkerStop() " << G4endl;
93
94#ifdef G4MULTITHREADED
95 G4AutoLock lm(&stopWorkerMutex);
96 delete TVirtualMCApplication::Instance();
97 lm.unlock();
98#endif
99
100 // G4cout << "TG4WorkerInitialization::WorkerStop() end " << G4endl;
101}
Definition of the TG4RunManager.h class.
Definition of the TG4WorkerInitialization class.
static TG4RunManager * Instance()
virtual void WorkerRunStart() const