|
||||
File indexing completed on 2025-01-18 09:55:21
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_DIGISEMAPHORE_H 0014 #define DDDIGI_DIGISEMAPHORE_H 0015 0016 /// Framework include files 0017 0018 /// C/C++ include files 0019 #include <mutex> 0020 #include <atomic> 0021 #include <condition_variable> 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 class DigiSemaphore; 0031 0032 /// Semaphore implementation, where object get notified when the reference count reaches NULL 0033 /** Semaphore implementation 0034 * object get notified when the reference count reaches NULL 0035 * 0036 * \author M.Frank 0037 * \version 1.0 0038 * \ingroup DD4HEP_DIGITIZATION 0039 */ 0040 class DigiSemaphore final { 0041 private: 0042 /// Reference count 0043 std::atomic<std::size_t> reference_count { 0UL }; 0044 /// Condition variable to wait until reference count is NULL 0045 std::condition_variable reference_count_is_null; 0046 /// Lock to handle condition variable 0047 std::mutex lock; 0048 0049 public: 0050 /// Default constructor: the one and only one 0051 DigiSemaphore() = default; 0052 /// Inhibit Move constructor 0053 DigiSemaphore(DigiSemaphore&& copy) = delete; 0054 /// Inhibit copy constructor 0055 DigiSemaphore(const DigiSemaphore& copy) = delete; 0056 /// Inhibit move assignment 0057 DigiSemaphore& operator=(DigiSemaphore&& copy) = delete; 0058 /// Inhibit copy assignment 0059 DigiSemaphore& operator=(const DigiSemaphore& copy) = delete; 0060 /// Default destructor. Decreasing reference count. 0061 ~DigiSemaphore() = default; 0062 0063 public: 0064 /// Wait until reference count is NULL. 0065 /** @return unique_lock [out] The semaphore is locks as long as the returned lock is held 0066 */ 0067 std::unique_lock<std::mutex> wait_null(); 0068 /// Aquire semaphore count 0069 void aquire(); 0070 /// Release semaphore count 0071 void release(); 0072 }; 0073 } // End namespace digi 0074 } // End namespace dd4hep 0075 #endif // DDDIGI_DIGISEMAPHORE_H
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |