MySQL 9.0.0
Source Code Documentation
raii::Thread_stage_guard Class Reference

RAII guard that sets a thread stage, and restores the previous stage when going out of scope. More...

#include <thread_stage_guard.h>

Public Member Functions

 Thread_stage_guard ()=delete
 
 Thread_stage_guard (THD *thd, const PSI_stage_info &new_stage, const char *func, const char *file, const unsigned int line)
 Set the given stage for the session, and remember the previous stage in a member variable. More...
 
 Thread_stage_guard (const Thread_stage_guard &)=delete
 
 Thread_stage_guard (Thread_stage_guard &&)=delete
 
Thread_stage_guardoperator= (const Thread_stage_guard &)=delete
 
Thread_stage_guardoperator= (Thread_stage_guard &&)=delete
 
void set_old_stage () const
 Revert back to the old stage before this object goes out of scope. More...
 
void set_new_stage () const
 Restore the new stage, in case set_old_stage was used earlier. More...
 
 ~Thread_stage_guard ()
 Revert the old stage that was used before this object's constructor was invoked. More...
 

Private Attributes

PSI_stage_info m_old_stage
 The previous stage. More...
 
PSI_stage_info m_new_stage
 The new stage. More...
 
THDm_thd
 The session. More...
 
const char * m_func
 The name of the calling function. More...
 
const char * m_file
 The filename of the caller. More...
 
const unsigned int m_line
 The Line number of the caller. More...
 

Detailed Description

RAII guard that sets a thread stage, and restores the previous stage when going out of scope.

Constructor & Destructor Documentation

◆ Thread_stage_guard() [1/4]

raii::Thread_stage_guard::Thread_stage_guard ( )
delete

◆ Thread_stage_guard() [2/4]

raii::Thread_stage_guard::Thread_stage_guard ( THD thd,
const PSI_stage_info new_stage,
const char *  func,
const char *  file,
const unsigned int  line 
)
inline

Set the given stage for the session, and remember the previous stage in a member variable.

Parameters
[in,out]thdSession object that should change stage.
new_stageThe new stage to use for THD.
funcName of the calling function.
fileFilename of the caller.
lineLine number of the caller.

◆ Thread_stage_guard() [3/4]

raii::Thread_stage_guard::Thread_stage_guard ( const Thread_stage_guard )
delete

◆ Thread_stage_guard() [4/4]

raii::Thread_stage_guard::Thread_stage_guard ( Thread_stage_guard &&  )
delete

◆ ~Thread_stage_guard()

raii::Thread_stage_guard::~Thread_stage_guard ( )
inline

Revert the old stage that was used before this object's constructor was invoked.

Note
This will set the function/filename/line number relating to where the Thread_stage_guard was created, not where it went out of scope.

Member Function Documentation

◆ operator=() [1/2]

Thread_stage_guard & raii::Thread_stage_guard::operator= ( const Thread_stage_guard )
delete

◆ operator=() [2/2]

Thread_stage_guard & raii::Thread_stage_guard::operator= ( Thread_stage_guard &&  )
delete

◆ set_new_stage()

void raii::Thread_stage_guard::set_new_stage ( ) const
inline

Restore the new stage, in case set_old_stage was used earlier.

◆ set_old_stage()

void raii::Thread_stage_guard::set_old_stage ( ) const
inline

Revert back to the old stage before this object goes out of scope.

Member Data Documentation

◆ m_file

const char* raii::Thread_stage_guard::m_file
private

The filename of the caller.

◆ m_func

const char* raii::Thread_stage_guard::m_func
private

The name of the calling function.

◆ m_line

const unsigned int raii::Thread_stage_guard::m_line
private

The Line number of the caller.

◆ m_new_stage

PSI_stage_info raii::Thread_stage_guard::m_new_stage
private

The new stage.

◆ m_old_stage

PSI_stage_info raii::Thread_stage_guard::m_old_stage
private

The previous stage.

◆ m_thd

THD* raii::Thread_stage_guard::m_thd
private

The session.


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