Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 10:12:39

0001 //==========================================================================
0002 //  AIDA Detector description implementation 
0003 //--------------------------------------------------------------------------
0004 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
0005 // All rights reserved.
0006 //
0007 // For the licensing terms see $DD4hepINSTALL/LICENSE.
0008 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
0009 //
0010 // Author     : M.Frank
0011 //
0012 //==========================================================================
0013 #ifndef DDDIGI_DIGIPARALLELWORKERGROUP_H
0014 #define DDDIGI_DIGIPARALLELWORKERGROUP_H
0015 
0016 /// Framework include files
0017 #include <DDDigi/DigiParallelWorker.h>
0018 
0019 /// C/C++ include files
0020 #include <cstdint>
0021 #include <vector>
0022 
0023 /// Namespace for the AIDA detector description toolkit
0024 namespace dd4hep {
0025 
0026   /// Namespace for the Digitization part of the AIDA detector description toolkit
0027   namespace digi {
0028 
0029     /// Forward declarations
0030     template <typename T> class DigiParallelWorkers;
0031     template <typename T> class DigiParallelWorkerGroup;
0032 
0033     /// Wrapper class to submit bulk actions
0034     /**
0035      *
0036      *  \author  M.Frank
0037      *  \version 1.0
0038      *  \ingroup DD4HEP_DIGITIZATION
0039      */
0040     template <typename T> class DigiParallelWorkerGroup  {
0041       /// Reference to worker collection with semaphore
0042       const DigiParallelWorkers<T>& workers;
0043 
0044     public:
0045       /// Initializin constructor: aquire worker's semaphore
0046       DigiParallelWorkerGroup(const DigiParallelWorkers<T>& workers);
0047       /// Inhibit Move constructor
0048       DigiParallelWorkerGroup(DigiParallelWorkerGroup&& copy) = delete;
0049       /// Inhibit copy constructor
0050       DigiParallelWorkerGroup(const DigiParallelWorkerGroup& copy) = delete;
0051       /// Inhibit move assignment
0052       DigiParallelWorkerGroup& operator=(DigiParallelWorkerGroup&& copy) = delete;
0053       /// Inhibit copy assignment
0054       DigiParallelWorkerGroup& operator=(const DigiParallelWorkerGroup& copy) = delete;
0055       /// Default destructor. Releasing semaphore
0056       ~DigiParallelWorkerGroup();
0057       /// Access the worker array. As long as the object persists it shall not be altered
0058       operator ParallelWorker*const* ();
0059       /// Access specific worker array from group: actors are locked while group exists
0060       std::vector<typename DigiParallelWorkers<T>::worker_t*>   actors()    {
0061     return workers.actors;
0062       }
0063     };
0064     
0065     /// Initializin constructor: aquire worker's semaphore
0066     template <typename T> inline 
0067       DigiParallelWorkerGroup<T>::DigiParallelWorkerGroup(const DigiParallelWorkers<T>& w)
0068       : workers(w) 
0069       {
0070     workers.semaphore.aquire();
0071       }
0072 
0073     /// Default destructor. Releasing semaphore
0074     template <typename T> inline DigiParallelWorkerGroup<T>::~DigiParallelWorkerGroup()   {
0075       workers.semaphore.release();
0076     }
0077 
0078     /// Access the worker array. As long as the object persists the array stays intact
0079     template <typename T> inline DigiParallelWorkerGroup<T>::operator ParallelWorker*const* ()   {
0080       return (ParallelWorker**)&this->workers.actors.at(0);
0081     }
0082 
0083   }    // End namespace digi
0084 }      // End namespace dd4hep
0085 #endif // DDDIGI_DIGIPARALLELWORKERGROUP_H