My Project
Public Member Functions
Thread_excursion Class Reference

List of all members.

Public Member Functions

 Thread_excursion (THD *thd)
void try_to_attach_to (THD *thd)

Detailed Description

Helper class to perform a thread excursion.

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 physial 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.

  {
    Thread_excursion excursion(current_thd);
    for (int i = 0 ; i < count ; ++i)
      excursion.attach_to(other_thd[i]);
  }
Warning:
The class is not designed to be inherited from.

Member Function Documentation

void Thread_excursion::try_to_attach_to ( THD *  thd) [inline]

Try to attach the POSIX thread to a session.

  • This function attaches the POSIX thread to a session in MAX_SESSION_ATTACH_TRIES tries when encountering 'out of memory' error, and terminates the server after failed in MAX_SESSION_ATTACH_TRIES tries.
Parameters:
[in]thdThe thd of a session

The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines