24#ifndef LOCK_SHARED_SPIN_LOCK_INCLUDED
25#define LOCK_SHARED_SPIN_LOCK_INCLUDED
109 bool try_and_fail =
false);
152 bool try_and_fail =
false);
Sentry class for Shared_spin_lock to deliver RAII pattern usability.
Definition: shared_spin_lock.h:91
Shared_spin_lock & operator*()
Star operator to access the underlying lock.
Definition: shared_spin_lock.cc:50
Guard(Shared_spin_lock &target, enum_lock_acquisition acquisition=enum_lock_acquisition::SL_SHARED, bool try_and_fail=false)
Class constructor that receives the target spin-lock, whether or not it can be a shared acquisition a...
Definition: shared_spin_lock.cc:33
Shared_spin_lock * operator->()
Arrow operator to access the underlying lock.
Definition: shared_spin_lock.cc:46
Shared_spin_lock::Guard & release()
Releases the underlying lock acquisition, if any.
Definition: shared_spin_lock.cc:91
virtual ~Guard()
Destructor for the sentry.
Definition: shared_spin_lock.cc:44
Guard(Shared_spin_lock::Guard const &)=delete
Shared_spin_lock::Guard & operator=(Shared_spin_lock::Guard const &)=delete
Guard(Shared_spin_lock::Guard &&)=delete
Shared_spin_lock::Guard & operator=(Shared_spin_lock::Guard &&)=delete
enum_lock_acquisition m_acquisition
The type of lock acquisition to be requested.
Definition: shared_spin_lock.h:164
Shared_spin_lock::Guard & acquire(enum_lock_acquisition acquisition, bool try_and_fail=false)
If this instance was initialized without acquiring the lock (NO_ACQUISITION passed to constructor) or...
Definition: shared_spin_lock.cc:54
Shared_spin_lock & m_target
The underlying lock.
Definition: shared_spin_lock.h:162
Definition: shared_spin_lock.h:80
memory::Aligned_atomic< bool > m_exclusive_access
Whether or not any thread is accessing in or waiting for exclusive mode.
Definition: shared_spin_lock.h:234
void spin_shared_lock()
Blocks until the lock is acquired in shared mode.
Definition: shared_spin_lock.cc:233
Shared_spin_lock & try_exclusive()
Tries to acquire the lock in exclusive mode.
Definition: shared_spin_lock.cc:124
enum_lock_acquisition
Definition: shared_spin_lock.h:82
Shared_spin_lock()=default
Default class constructor.
bool try_shared_lock()
Tries to acquire in shared mode.
Definition: shared_spin_lock.cc:208
void spin_exclusive_lock()
Blocks until the lock is acquired in exclusive mode.
Definition: shared_spin_lock.cc:252
bool is_shared_acquisition()
Returns whether the lock is acquired for shared access by the invoking thread.
Definition: shared_spin_lock.cc:158
Shared_spin_lock & try_or_spin_shared_lock(bool try_and_fail)
Tries to lock or waits for locking in shared mode and increases the thread-local lock acquisition sha...
Definition: shared_spin_lock.cc:170
static std::map< Shared_spin_lock *, long > & acquired_spins()
Returns the thread-local lock counter map.
Definition: shared_spin_lock.cc:262
bool try_exclusive_lock()
Tries to acquire in exclusive mode.
Definition: shared_spin_lock.cc:222
Shared_spin_lock & try_shared()
Tries to acquire the lock in shared mode.
Definition: shared_spin_lock.cc:120
Shared_spin_lock & try_or_spin_exclusive_lock(bool try_and_fail)
Tries to lock or waits for locking in shared mode and increases the thread-local lock acquisition sha...
Definition: shared_spin_lock.cc:189
Shared_spin_lock & release_shared()
Releases the previously granted shared acquisition request.
Definition: shared_spin_lock.cc:128
Shared_spin_lock & acquire_shared()
Blocks until the lock is acquired in shared mode.
Definition: shared_spin_lock.cc:112
memory::Aligned_atomic< long > m_shared_access
The total amount of threads accessing in shared mode
Definition: shared_spin_lock.h:232
Shared_spin_lock & release_exclusive()
Releases the previously granted exclusive acquisition request.
Definition: shared_spin_lock.cc:143
virtual ~Shared_spin_lock()=default
Default class destructor.
Shared_spin_lock & acquire_exclusive()
Blocks until the lock is acquired in exclusive mode.
Definition: shared_spin_lock.cc:116
bool is_exclusive_acquisition()
Returns whether the lock is acquired for exclusive access by the invoking thread.
Definition: shared_spin_lock.cc:164
Templated class that encapsulates an std::atomic within a byte buffer that is padded to the processor...
Definition: aligned_atomic.h:158
Provides atomic access in shared-exclusive modes.
Definition: shared_spin_lock.h:79