MySQL 8.0.39
Source Code Documentation
|
Sentry class for managing the need to create and dispose of a local THD
instance.
More...
#include <rpl_utility.h>
Public Member Functions | |
THD_instance_guard (THD *thd) | |
If the given THD object pointer is nullptr , a new instance will be initialized within the constructor and disposed of in the destructor. More... | |
virtual | ~THD_instance_guard () |
If a new instance of THD was created in the constructor, it will be disposed here. More... | |
operator THD * () | |
Returns the active THD object pointer. More... | |
Private Attributes | |
THD * | m_target {nullptr} |
The active THD object pointer. More... | |
bool | m_is_locally_initialized {false} |
Tells whether or not the active THD object was created in this object constructor. More... | |
Sentry class for managing the need to create and dispose of a local THD
instance.
If the given THD
object pointer passed on the constructor is nullptr
, a new instance will be initialized within the constructor and disposed of in the destructor.
If the given THD
object pointer passed on the constructor is not nullptr
, the reference is kept and nothing is disposed on the destructor.
Casting operator to THD*
is also provided, to easy code replacemente.
Usage example:
THD_instance_guard thd{current_thd != nullptr ? current_thd : this->info_thd}; Acl_cache_lock_guard guard{thd, Acl_cache_lock_mode::READ_MODE}; if (guard.lock()) ...
THD_instance_guard::THD_instance_guard | ( | THD * | thd | ) |
If the given THD
object pointer is nullptr
, a new instance will be initialized within the constructor and disposed of in the destructor.
If the given THD
object pointer is not nullptr
, the reference is kept and nothing is disposed on the destructor.
thd | THD object reference that determines if an existence instance is used or a new instance of THD must be created. |
|
virtual |
If a new instance of THD
was created in the constructor, it will be disposed here.
THD_instance_guard::operator THD * | ( | ) |
Returns the active THD
object pointer.
THD
object pointer.
|
private |
Tells whether or not the active THD
object was created in this object constructor.