MySQL 8.3.0
Source Code Documentation
MDL_lock_guard Class Reference

Utility class to allow RAII pattern with MDL_request and MDL_context classes. More...

#include <rpl_rli.h>

Public Member Functions

 MDL_lock_guard (THD *target)
 Constructor that initializes the object and the target THD object but doesn't try to acquire any lock. More...
 
 MDL_lock_guard (THD *target, MDL_key::enum_mdl_namespace namespace_arg, enum_mdl_type mdl_type_arg, bool blocking=false)
 Constructor that initializes the object and the target THD object and tries to acquire the lock identified by namespace_arg with MDL type identified by mdl_type_arg. More...
 
virtual ~MDL_lock_guard ()
 Destructor that unlocks all acquired locks. More...
 
bool lock (MDL_key::enum_mdl_namespace namespace_arg, enum_mdl_type mdl_type_arg, bool blocking=false)
 Uses the target THD object MDL context to acquire the lock identified by namespace_arg with MDL type identified by mdl_type_arg. More...
 
bool is_locked ()
 Returns whether or not the lock as been acquired within this object life-cycle. More...
 

Private Attributes

THDm_target
 The THD object holding the MDL context used for acquiring/releasing. More...
 
MDL_request m_request
 The MDL request holding the MDL ticket issued upon acquisition. More...
 

Detailed Description

Utility class to allow RAII pattern with MDL_request and MDL_context classes.

Constructor & Destructor Documentation

◆ MDL_lock_guard() [1/2]

MDL_lock_guard::MDL_lock_guard ( THD target)

Constructor that initializes the object and the target THD object but doesn't try to acquire any lock.

Parameters
targetTHD object, source for the MDL_context to use.

◆ MDL_lock_guard() [2/2]

MDL_lock_guard::MDL_lock_guard ( THD target,
MDL_key::enum_mdl_namespace  namespace_arg,
enum_mdl_type  mdl_type_arg,
bool  blocking = false 
)

Constructor that initializes the object and the target THD object and tries to acquire the lock identified by namespace_arg with MDL type identified by mdl_type_arg.

If the blocking parameter is true, it will instantly try to acquire the lock and block. If the blocking parameter is false, it will first test if the lock is already acquired and only try to lock if no conflicting lock is already acquired.

Parameters
targetTHD object, source for the MDL_context to use.
namespace_argMDL key namespace to acquire the lock from.
mdl_type_argMDL acquisition type
blockingwhether or not the execution should block if the lock is already acquired.

◆ ~MDL_lock_guard()

MDL_lock_guard::~MDL_lock_guard ( )
virtual

Destructor that unlocks all acquired locks.

Member Function Documentation

◆ is_locked()

bool MDL_lock_guard::is_locked ( )

Returns whether or not the lock as been acquired within this object life-cycle.

Returns
true if the lock has been acquired within this object life-cycle.

◆ lock()

bool MDL_lock_guard::lock ( MDL_key::enum_mdl_namespace  namespace_arg,
enum_mdl_type  mdl_type_arg,
bool  blocking = false 
)

Uses the target THD object MDL context to acquire the lock identified by namespace_arg with MDL type identified by mdl_type_arg.

If the blocking parameter is true, it will instantly try to acquire the lock and block. If the blocking parameter is false, it will first test if the lock is already acquired and only try to lock if no conflicting lock is already acquired.

The lock is determined to have been acquired if the THD object MDL context hasn't already a lock and the lock is acquired. In other words, if the MDL context already has acquired the lock, the method will return failure.

Parameters
namespace_argMDL key namespace to acquire the lock from.
mdl_type_argMDL acquisition type
blockingwhether or not the execution should block if the lock is already acquired.
Returns
false if the lock has been acquired by this method invocation and true if not.

Member Data Documentation

◆ m_request

MDL_request MDL_lock_guard::m_request
private

The MDL request holding the MDL ticket issued upon acquisition.

◆ m_target

THD* MDL_lock_guard::m_target
private

The THD object holding the MDL context used for acquiring/releasing.


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