Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 09:17:15

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 
0014 // Framework include files
0015 #include <DDDigi/DigiSemaphore.h>
0016 
0017 using namespace dd4hep::digi;
0018 
0019 /// Wait until reference count is NULL
0020 std::unique_lock<std::mutex> DigiSemaphore::wait_null()  {
0021   std::unique_lock<std::mutex> protect(this->lock);
0022   this->reference_count_is_null.wait(protect, [this] { return this->reference_count == 0; } );
0023   return protect;
0024 }
0025 
0026 /// Aquire semaphore count
0027 void DigiSemaphore::aquire()   {
0028   std::lock_guard guard(this->lock);
0029   ++this->reference_count;
0030 }
0031 
0032 /// Release semaphore count
0033 void DigiSemaphore::release()  {
0034   if ( --this->reference_count == 0 )
0035     this->reference_count_is_null.notify_one();
0036 }