CommonLibSSE (powerof3)
Loading...
Searching...
No Matches
BSAtomic.h
Go to the documentation of this file.
1#pragma once
2
3#include "REX/W32/BASE.h"
4
5namespace RE
6{
7 template <class T>
9 {
10 public:
11 static_assert(std::is_integral_v<T>);
12
13 constexpr BSTAtomicValue() noexcept = default;
14 explicit constexpr BSTAtomicValue(T a_rhs) noexcept :
15 _value(a_rhs)
16 {}
17
19 {
20 stl::atomic_ref value{ _value };
21 return ++value;
22 }
23 [[nodiscard]] T operator++(int)
24 {
25 stl::atomic_ref value{ _value };
26 return value++;
27 }
29 {
30 stl::atomic_ref value{ _value };
31 return --value;
32 }
33 [[nodiscard]] T operator--(int)
34 {
35 stl::atomic_ref value{ _value };
36 return value--;
37 }
38
39 [[nodiscard]] T& load_unchecked() noexcept { return _value; }
40 [[nodiscard]] const T& load_unchecked() const noexcept { return _value; }
41
42 private:
43 // members
44 T _value{ 0 }; // 0
45 };
46 static_assert(sizeof(BSTAtomicValue<std::uint32_t>) == 0x4);
47
49 {
50 public:
51 // members
53 };
54 static_assert(sizeof(BSCriticalSection) == 0x28);
55
57 {
58 public:
59 // members
60 void* event; // 0
61 };
62 static_assert(sizeof(BSEventFlag) == 0x8);
63
65 {
66 public:
67 // members
68 volatile std::uint32_t lock; // 0
69 };
70 static_assert(sizeof(BSNonReentrantSpinLock) == 0x4);
71
73 {
74 public:
77
78 // members
79 void* semaphore; // 0
80 };
81 static_assert(sizeof(BSSemaphoreBase) == 0x8);
82
84 {
85 public:
86 BSSemaphore() = default;
87 ~BSSemaphore() = default;
88 };
89 static_assert(sizeof(BSSemaphore) == 0x8);
90
92 {
93 public:
94 enum
95 {
97 };
98
100
101 void Lock(std::uint32_t a_pauseAttempts = 0);
102 void Unlock();
103
104 private:
105 // members
106 volatile std::uint32_t _owningThread; // 0
107 volatile std::uint32_t _lockCount; // 4
108 };
109 static_assert(sizeof(BSSpinLock) == 0x8);
110
112 {
113 public:
114 enum
115 {
116 kLockWrite = 0x80000000,
117 kLockCountMask = 0xFFFFFFF
118 };
119
121
126
127 private:
128 // members
129 volatile std::uint32_t _writerThread; // 0
130 volatile std::uint32_t _lock; // 4
131 };
132 static_assert(sizeof(BSReadWriteLock) == 0x8);
133
135 {
136 public:
137 BSSpinLockGuard() = delete;
140 [[nodiscard]] explicit BSSpinLockGuard(BSSpinLock& a_lock);
142
145
146 private:
147 BSSpinLock& _lock; // 0
148 };
149 static_assert(sizeof(BSSpinLockGuard) == 0x8);
150
152 {
153 public:
154 BSReadLockGuard() = delete;
157 [[nodiscard]] explicit BSReadLockGuard(BSReadWriteLock& a_lock);
159
162
163 private:
164 BSReadWriteLock& _lock; // 0
165 };
166 static_assert(sizeof(BSReadLockGuard) == 0x8);
167
169 {
170 public:
174 [[nodiscard]] explicit BSWriteLockGuard(BSReadWriteLock& a_lock);
176
179
180 private:
181 BSReadWriteLock& _lock; // 0
182 };
183 static_assert(sizeof(BSWriteLockGuard) == 0x8);
184}
Definition BSAtomic.h:49
REX::W32::CRITICAL_SECTION criticalSection
Definition BSAtomic.h:52
Definition BSAtomic.h:57
void * event
Definition BSAtomic.h:60
Definition BSAtomic.h:65
volatile std::uint32_t lock
Definition BSAtomic.h:68
Definition BSAtomic.h:152
BSReadLockGuard(BSReadLockGuard &&)=delete
BSReadLockGuard & operator=(BSReadLockGuard &&)=delete
BSReadLockGuard(BSReadWriteLock &a_lock)
BSReadLockGuard(const BSReadLockGuard &)=delete
BSReadLockGuard()=delete
BSReadLockGuard & operator=(const BSReadLockGuard &)=delete
Definition BSAtomic.h:112
@ kLockCountMask
Definition BSAtomic.h:117
@ kLockWrite
Definition BSAtomic.h:116
Definition BSAtomic.h:73
void * semaphore
Definition BSAtomic.h:79
Definition BSAtomic.h:84
BSSemaphore()=default
~BSSemaphore()=default
Definition BSAtomic.h:135
BSSpinLockGuard(BSSpinLock &a_lock)
BSSpinLockGuard(const BSSpinLockGuard &)=delete
BSSpinLockGuard(BSSpinLockGuard &&)=delete
BSSpinLockGuard()=delete
BSSpinLockGuard & operator=(BSSpinLockGuard &&)=delete
BSSpinLockGuard & operator=(const BSSpinLockGuard &)=delete
Definition BSAtomic.h:92
@ kFastSpinThreshold
Definition BSAtomic.h:96
void Lock(std::uint32_t a_pauseAttempts=0)
Definition BSAtomic.h:9
T operator++(int)
Definition BSAtomic.h:23
T operator--()
Definition BSAtomic.h:28
T & load_unchecked() noexcept
Definition BSAtomic.h:39
const T & load_unchecked() const noexcept
Definition BSAtomic.h:40
constexpr BSTAtomicValue() noexcept=default
T operator++()
Definition BSAtomic.h:18
T operator--(int)
Definition BSAtomic.h:33
Definition BSAtomic.h:169
BSWriteLockGuard(const BSWriteLockGuard &)=delete
BSWriteLockGuard & operator=(BSWriteLockGuard &&)=delete
BSWriteLockGuard & operator=(const BSWriteLockGuard &)=delete
BSWriteLockGuard(BSReadWriteLock &a_lock)
BSWriteLockGuard(BSWriteLockGuard &&)=delete
Definition PCH.h:246
Definition AbsorbEffect.h:6
Definition BASE.h:138