File indexing completed on 2025-09-17 09:14:33
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef ROOT_RSLOTSTACK
0012 #define ROOT_RSLOTSTACK
0013
0014 #include <atomic>
0015 #include <vector>
0016
0017 namespace ROOT {
0018 namespace Internal {
0019
0020
0021
0022
0023
0024
0025 class RSlotStack {
0026 struct alignas(8) AtomicWrapper {
0027 std::atomic_bool fAtomic{false};
0028 AtomicWrapper() = default;
0029 ~AtomicWrapper() = default;
0030 AtomicWrapper(const AtomicWrapper &) = delete;
0031 AtomicWrapper &operator=(const AtomicWrapper &) = delete;
0032 AtomicWrapper(AtomicWrapper &&other) { fAtomic = other.fAtomic.load(); }
0033 AtomicWrapper &operator=(AtomicWrapper &&other)
0034 {
0035 fAtomic = other.fAtomic.load();
0036 return *this;
0037 }
0038 };
0039 std::vector<AtomicWrapper> fSlots;
0040
0041 public:
0042 RSlotStack() = delete;
0043 RSlotStack(unsigned int size);
0044 void ReturnSlot(unsigned int slotNumber);
0045 unsigned int GetSlot();
0046 };
0047
0048
0049
0050 struct RSlotStackRAII {
0051 ROOT::Internal::RSlotStack &fSlotStack;
0052 const unsigned int fSlot;
0053 RSlotStackRAII(ROOT::Internal::RSlotStack &slotStack) : fSlotStack(slotStack), fSlot(slotStack.GetSlot()) {}
0054 ~RSlotStackRAII() { fSlotStack.ReturnSlot(fSlot); }
0055 };
0056
0057 }
0058 }
0059
0060 #endif