Helper class to switch to a new thread and then go back to the previous one, when the object is destroyed using RAII.
More...
Helper class to switch to a new thread and then go back to the previous one, when the object is destroyed using RAII.
This class is used to temporarily switch to another session (THD structure). It will set up thread specific "globals" correctly so that the POSIX thread looks exactly like the session attached to. However, PSI_thread info is not touched as it is required to show the actual physical view in PFS instrumentation i.e., it should depict as the real thread doing the work instead of thread it switched to.
On destruction, the original session (which is supplied to the constructor) will be re-attached automatically. For example, with this code, the value of current_thd
will be the same before and after execution of the code.
{
for (
int i = 0 ; i <
count ; ++i)
{
}
}
Helper class to switch to a new thread and then go back to the previous one, when the object is destr...
Definition: binlog.cc:640
thread_local THD * current_thd
Definition: current_thd.cc:26
static int count
Definition: myisam_ftdump.cc:45
- Warning
- The class is not designed to be inherited from.