File indexing completed on 2025-01-18 10:10:51
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #ifndef ROOT_TRWSpinLock
0014 #define ROOT_TRWSpinLock
0015
0016 #include "TSpinMutex.hxx"
0017
0018 #include <atomic>
0019 #include <condition_variable>
0020
0021 namespace ROOT {
0022 class TRWSpinLock {
0023 private:
0024 std::atomic<int> fReaders;
0025 std::atomic<int> fReaderReservation;
0026 std::atomic<int> fWriterReservation;
0027 std::atomic<bool> fWriter;
0028 ROOT::TSpinMutex fMutex;
0029 std::condition_variable_any fCond;
0030
0031 public:
0032
0033
0034 TRWSpinLock() : fReaders(0), fReaderReservation(0), fWriterReservation(0), fWriter(false) {}
0035
0036 void ReadLock();
0037 void ReadUnLock();
0038 void WriteLock();
0039 void WriteUnLock();
0040 };
0041
0042 class TRWSpinLockReadGuard {
0043 private:
0044 TRWSpinLock &fLock;
0045
0046 public:
0047 TRWSpinLockReadGuard(TRWSpinLock &lock);
0048 ~TRWSpinLockReadGuard();
0049 };
0050
0051 class TRWSpinLockWriteGuard {
0052 private:
0053 TRWSpinLock &fLock;
0054
0055 public:
0056 TRWSpinLockWriteGuard(TRWSpinLock &lock);
0057 ~TRWSpinLockWriteGuard();
0058 };
0059
0060 }
0061
0062 #endif