MySQL 8.0.39
Source Code Documentation
lock::Shared_spin_lock::Guard Class Reference

Sentry class for Shared_spin_lock to deliver RAII pattern usability. More...

#include <shared_spin_lock.h>

Public Member Functions

 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 and whether or not it should be a try-and-fail lock attempt, instead of a blocking attempt. More...
 
 Guard (Shared_spin_lock::Guard const &)=delete
 
 Guard (Shared_spin_lock::Guard &&)=delete
 
virtual ~Guard ()
 Destructor for the sentry. More...
 
Shared_spin_lock::Guardoperator= (Shared_spin_lock::Guard const &)=delete
 
Shared_spin_lock::Guardoperator= (Shared_spin_lock::Guard &&)=delete
 
Shared_spin_lockoperator-> ()
 Arrow operator to access the underlying lock. More...
 
Shared_spin_lockoperator* ()
 Star operator to access the underlying lock. More...
 
Shared_spin_lock::Guardacquire (enum_lock_acquisition acquisition, bool try_and_fail=false)
 If this instance was initialized without acquiring the lock (NO_ACQUISITION passed to constructor) or the acquisition request wasn't granted (passing try_and_fail = true to the constructor), invoking this method will try to acquire the lock in the provided mode. More...
 
Shared_spin_lock::Guardrelease ()
 Releases the underlying lock acquisition, if any. More...
 

Private Attributes

Shared_spin_lockm_target
 The underlying lock. More...
 
enum_lock_acquisition m_acquisition {enum_lock_acquisition::SL_SHARED}
 The type of lock acquisition to be requested. More...
 

Friends

class Shared_spin_lock
 

Detailed Description

Sentry class for Shared_spin_lock to deliver RAII pattern usability.

Constructor & Destructor Documentation

◆ Guard() [1/3]

lock::Shared_spin_lock::Guard::Guard ( lock::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 and whether or not it should be a try-and-fail lock attempt, instead of a blocking attempt.

Parameters
targetThe target spin-lock.
acquisitionthe acquisition type, SHARED, EXCLUSIVE or NO_ACQUISITION
try_and_failwhether or not the lock attempt should be blocking (only used if acquisition type is SHARED or EXCLUSIVE).

◆ Guard() [2/3]

lock::Shared_spin_lock::Guard::Guard ( Shared_spin_lock::Guard const &  )
delete

◆ Guard() [3/3]

lock::Shared_spin_lock::Guard::Guard ( Shared_spin_lock::Guard &&  )
delete

◆ ~Guard()

lock::Shared_spin_lock::Guard::~Guard ( )
virtual

Destructor for the sentry.

It will release any acquisition, shared or exclusive.

Member Function Documentation

◆ acquire()

lock::Shared_spin_lock::Guard & lock::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 the acquisition request wasn't granted (passing try_and_fail = true to the constructor), invoking this method will try to acquire the lock in the provided mode.

Parameters
acquisitionthe acquisition type, SHARED or EXCLUSIVE
try_and_failwhether or not the lock attempt should be blocking
Returns
A reference to this object, for chaining purposes.

◆ operator*()

lock::Shared_spin_lock & lock::Shared_spin_lock::Guard::operator* ( )

Star operator to access the underlying lock.

Returns
A reference to the underlying lock.

◆ operator->()

lock::Shared_spin_lock * lock::Shared_spin_lock::Guard::operator-> ( )

Arrow operator to access the underlying lock.

Returns
A pointer to the underlying lock.

◆ operator=() [1/2]

Shared_spin_lock::Guard & lock::Shared_spin_lock::Guard::operator= ( Shared_spin_lock::Guard &&  )
delete

◆ operator=() [2/2]

Shared_spin_lock::Guard & lock::Shared_spin_lock::Guard::operator= ( Shared_spin_lock::Guard const &  )
delete

◆ release()

lock::Shared_spin_lock::Guard & lock::Shared_spin_lock::Guard::release ( )

Releases the underlying lock acquisition, if any.

Returns
A reference to this object, for chaining purposes.

Friends And Related Function Documentation

◆ Shared_spin_lock

friend class Shared_spin_lock
friend

Member Data Documentation

◆ m_acquisition

enum_lock_acquisition lock::Shared_spin_lock::Guard::m_acquisition {enum_lock_acquisition::SL_SHARED}
private

The type of lock acquisition to be requested.

◆ m_target

Shared_spin_lock& lock::Shared_spin_lock::Guard::m_target
private

The underlying lock.


The documentation for this class was generated from the following files: