Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-21 10:00:28

0001 /***********************************************************************************\
0002 * (c) Copyright 1998-2019 CERN for the benefit of the LHCb and ATLAS collaborations *
0003 *                                                                                   *
0004 * This software is distributed under the terms of the Apache version 2 licence,     *
0005 * copied verbatim in the file "LICENSE".                                            *
0006 *                                                                                   *
0007 * In applying this licence, CERN does not waive the privileges and immunities       *
0008 * granted to it by virtue of its status as an Intergovernmental Organization        *
0009 * or submit itself to any jurisdiction.                                             *
0010 \***********************************************************************************/
0011 #ifndef GAUDIKERNEL_CONCURRENCYFLAGS_H
0012 #define GAUDIKERNEL_CONCURRENCYFLAGS_H 1
0013 
0014 #include <cstddef>
0015 
0016 #include "GaudiKernel/Kernel.h"
0017 
0018 class ThreadPoolSvc;
0019 class HiveWhiteBoard;
0020 class SGHiveMgrSvc;
0021 class AthMpEvtLoopMgr;
0022 class EvtStoreSvc;
0023 
0024 /** @class ConcurrencyFlags ConcurrencyFlags.h GaudiKernel/ConcurrencyFlags.h
0025  *
0026  * Provides information about the level of concurrency of the currently
0027  * executing job
0028  *
0029  * will enumerate the number of Worker Threads (for multi-threading),
0030  * Processes (for multi-processing), and total number of concurrent events.
0031  *
0032  */
0033 
0034 namespace SG {
0035   class HiveMgrSvc;
0036 }
0037 
0038 namespace Gaudi {
0039 
0040   namespace Concurrency {
0041 
0042     class ConcurrencyFlags {
0043 
0044       friend class ::ThreadPoolSvc;
0045       friend class ::HiveWhiteBoard;
0046       friend class ::EvtStoreSvc;
0047       friend class SG::HiveMgrSvc;    // ATLAS
0048       friend class ::AthMpEvtLoopMgr; // ATLAS
0049 
0050     public:
0051       /** number of Worker Threads (for MT)
0052        */
0053       static GAUDI_API std::size_t numThreads() { return n_threads; }
0054 
0055       /** number of Concurrent Events (for MT)
0056        */
0057       static GAUDI_API std::size_t numConcurrentEvents() { return n_concEvts; }
0058 
0059       /** number of forked child processes (for MP)
0060        */
0061       static GAUDI_API std::size_t numProcs() { return n_procs; }
0062 
0063       /** serial operation, or some form of concurrency
0064        */
0065       static GAUDI_API bool concurrent() { return ( n_threads || n_concEvts || n_procs ); }
0066 
0067     private:
0068       static GAUDI_API void setNumThreads( const std::size_t& nT ) { n_threads = nT; }
0069       static GAUDI_API void setNumConcEvents( const std::size_t& nE ) { n_concEvts = nE; }
0070       static GAUDI_API void setNumProcs( const std::size_t& nP ) { n_procs = nP; }
0071 
0072     private:
0073       static std::size_t n_threads;  // worker threads for MT
0074       static std::size_t n_concEvts; // concurrent events for MT
0075       static std::size_t n_procs;    // child processes for MP
0076     };
0077   } // namespace Concurrency
0078 } // namespace Gaudi
0079 
0080 #endif