Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:59:17

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 // Author: Jonathan Madsen (May 28st 2020)
0027 //
0028 // class description:
0029 //
0030 //      This class is used for multi-threaded Geant4.
0031 //      It encapsulates the mechanism of starting/stopping threads.
0032 
0033 #ifndef G4UserTaskThreadInitialization_hh
0034 #define G4UserTaskThreadInitialization_hh
0035 
0036 class G4VUserPrimaryGeneratorAction;
0037 class G4UserRunAction;
0038 class G4UserEventAction;
0039 class G4UserStackingAction;
0040 class G4UserTrackingAction;
0041 class G4UserSteppingAction;
0042 
0043 class G4WorkerThread;
0044 class G4WorkerTaskRunManager;
0045 
0046 #include "G4Threading.hh"
0047 #include "G4UserWorkerThreadInitialization.hh"
0048 #include "Randomize.hh"
0049 
0050 class G4UserTaskThreadInitialization : public G4UserWorkerThreadInitialization
0051 {
0052   public:  // with description
0053     G4UserTaskThreadInitialization() = default;
0054     ~G4UserTaskThreadInitialization() override = default;
0055 
0056     //  Called by the kernel to create a new thread/worker
0057     //  and start work.
0058     // Usere should not re-implement this function (in derived class), except only
0059     // if he/she wants to verwrite the default threading model (see StartThread
0060     // function)
0061     G4Thread* CreateAndStartWorker(G4WorkerThread* workerThreadContext) override;
0062 
0063     // Called by worker threads to set the Random Number Generator Engine
0064     // The default implementation "clones" the engine from the master thread
0065     // User needs to re-implement this method if using a non-standard
0066     // RNG Engine (i.e. a different one w.r.t. the one provided in the CLHEP
0067     // version supported by G4.
0068     // Important: this method is called by all threads at the same time
0069     //   if is user responsibilitiy to make it thread-safe
0070     void SetupRNGEngine(const CLHEP::HepRandomEngine* aRNGEngine) const override;
0071 
0072     // Called by the kernel when threads need to be terminated. Implements logic
0073     // of joining the aThread. Calling thread will wait for aThread to end. Usere
0074     // should not re-implement this function (in derived class), except only if
0075     // he/she wants to verwrite the default threading model (see StartThread
0076     // function)
0077     void JoinWorker(G4Thread* aThread) override;
0078 
0079     // Called by StartThread function to create a run-manager implementing worker
0080     // behvior. User should re-implemtn this function in derived class to
0081     // instantiate his/her user-defined WorkerRunManager. By default this method
0082     // instantiates G4WorkerTaskRunManager object.
0083     G4WorkerRunManager* CreateWorkerRunManager() const override;
0084 };
0085 
0086 #endif  // G4UserTaskThreadInitialization_hh