Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 10:36:45

0001 
0002 // Copyright 2020, Jefferson Science Associates, LLC.
0003 // Subject to the terms in the LICENSE file found in the top-level directory.
0004 
0005 
0006 #ifndef BDXRECO_JGLOBALROOTLOCK_H
0007 #define BDXRECO_JGLOBALROOTLOCK_H
0008 
0009 #include "JServiceLocator.h"
0010 
0011 
0012 class JGlobalRootLock : public JService {
0013 
0014 public:
0015 
0016     JGlobalRootLock() {
0017         m_root_rw_lock = new pthread_rwlock_t;
0018         pthread_rwlock_init(m_root_rw_lock, nullptr);
0019     }
0020 
0021     ~JGlobalRootLock() {
0022         delete m_root_rw_lock;
0023         m_root_rw_lock = nullptr;
0024     }
0025 
0026     inline void acquire_read_lock() { pthread_rwlock_rdlock(m_root_rw_lock); }
0027 
0028     inline void acquire_write_lock() { pthread_rwlock_wrlock(m_root_rw_lock); }
0029 
0030     inline void release_lock() { pthread_rwlock_unlock(m_root_rw_lock); }
0031 
0032 private:
0033 
0034     pthread_rwlock_t* m_root_rw_lock;
0035 
0036 };
0037 
0038 #endif //BDXRECO_JGLOBALROOTLOCK_H
0039 
0040 
0041