CatapultServer
v0.5.0.1 (Elephant)
|
Go to the documentation of this file.
27 namespace catapult {
namespace utils {
35 template<
typename TReaderNotificationPolicy>
48 #pragma push_macro("Yield")
51 std::this_thread::yield();
53 #pragma pop_macro("Yield")
102 explicit ReaderLockGuard(std::atomic<uint16_t>& value, TReaderNotificationPolicy& notificationPolicy)
103 :
LockGuard([&value, ¬ificationPolicy]() {
106 notificationPolicy.readerReleased();
110 notificationPolicy.readerAcquired();
165 if (
m_value.compare_exchange_strong(current, desired))
191 inline bool isSet(uint16_t mask)
const {
211 #ifdef ENABLE_CATAPULT_DIAGNOSTICS
215 namespace catapult {
namespace utils {
217 #ifdef ENABLE_CATAPULT_DIAGNOSTICS
LockGuard(const action &resetFunc)
Definition: SpinReaderWriterLock.h:59
void markActiveWriter()
Definition: SpinReaderWriterLock.h:134
WriterLockGuard promoteToWriter()
Definition: SpinReaderWriterLock.h:117
static constexpr uint16_t Pending_Writer_Mask
Definition: SpinReaderWriterLock.h:40
static constexpr uint16_t Active_Writer_Flag
Definition: SpinReaderWriterLock.h:39
BasicSpinReaderWriterLock()
Creates an unlocked lock.
Definition: SpinReaderWriterLock.h:148
~LockGuard()
Definition: SpinReaderWriterLock.h:64
static constexpr uint16_t Pending_Writer_Increment
Definition: SpinReaderWriterLock.h:45
static void Yield()
Definition: SpinReaderWriterLock.h:50
action m_resetFunc
Definition: SpinReaderWriterLock.h:77
NoOpReaderNotificationPolicy DefaultReaderNotificationPolicy
Definition: SpinReaderWriterLock.h:220
WriterLockGuard(std::atomic< uint16_t > &value, bool &isActive)
Creates a guard around value and isActive.
Definition: SpinReaderWriterLock.h:86
std::atomic< uint16_t > m_value
Definition: SpinReaderWriterLock.h:196
static constexpr uint16_t Active_Reader_Increment
Definition: SpinReaderWriterLock.h:44
ReaderLockGuard acquireReader()
Blocks until a reader lock can be acquired.
Definition: SpinReaderWriterLock.h:153
Base class for RAII lock guards.
Definition: SpinReaderWriterLock.h:57
A writer lock guard.
Definition: SpinReaderWriterLock.h:83
ReaderLockGuard(std::atomic< uint16_t > &value, TReaderNotificationPolicy ¬ificationPolicy)
Creates a guard around value and notificationPolicy.
Definition: SpinReaderWriterLock.h:102
std::function< void()> action
An action function.
Definition: functions.h:27
bool isSet(uint16_t mask) const
Definition: SpinReaderWriterLock.h:191
#define CATAPULT_THROW_RUNTIME_ERROR(MESSAGE)
Macro used to throw a catapult runtime error.
Definition: exceptions.h:167
A reader lock guard.
Definition: SpinReaderWriterLock.h:99
static constexpr uint16_t Writer_Mask
Definition: SpinReaderWriterLock.h:42
constexpr void readerAcquired()
A reader was acquried by the current thread.
Definition: SpinReaderWriterLock.h:202
bool m_isMoved
Definition: SpinReaderWriterLock.h:78
constexpr void readerReleased()
A reader was released by the current thread.
Definition: SpinReaderWriterLock.h:206
Definition: AddressExtractionExtension.cpp:28
bool isWriterActive() const
Returns true if there is an active writer.
Definition: SpinReaderWriterLock.h:181
A no-op reader notification policy.
Definition: SpinReaderWriterLock.h:200
static constexpr uint16_t Reader_Mask
Definition: SpinReaderWriterLock.h:41
bool isReaderActive() const
Returns true if there is an active reader.
Definition: SpinReaderWriterLock.h:186
bool isWriterPending() const
Returns true if there is a pending (or active) writer.
Definition: SpinReaderWriterLock.h:176
Definition: SpinReaderWriterLock.h:36
std::atomic< uint16_t > & m_value
Definition: SpinReaderWriterLock.h:142
LockGuard(LockGuard &&rhs)
Definition: SpinReaderWriterLock.h:72
bool m_isWriterActive
Definition: SpinReaderWriterLock.h:143