MySQL  8.0.18
Source Code Documentation
my_thr_init.cc File Reference

Functions to handle initialization and allocation of all mysys & debug thread variables. More...

#include <stdlib.h>
#include <sys/types.h>
#include <time.h>
#include "my_dbug.h"
#include "my_inttypes.h"
#include "my_loglevel.h"
#include "my_macros.h"
#include "my_psi_config.h"
#include "my_sys.h"
#include "my_systime.h"
#include "my_thread.h"
#include "my_thread_local.h"
#include "mysql/psi/mysql_cond.h"
#include "mysql/psi/mysql_mutex.h"
#include "mysql/psi/mysql_thread.h"
#include "mysql/psi/psi_thread.h"
#include "mysys/mysys_priv.h"
#include "mysys_err.h"
#include "thr_mutex.h"

Classes

struct  st_my_thread_var
 

Functions

static struct st_my_thread_varmysys_thread_var ()
 
static int set_mysys_thread_var (struct st_my_thread_var *mysys_var)
 
void my_thread_global_reinit ()
 Re-initialize components initialized early with my_thread_global_init. More...
 
bool my_thread_global_init ()
 initialize thread environment More...
 
void my_thread_global_end ()
 
bool my_thread_init ()
 Allocate thread specific memory for the thread, used by mysys and dbug. More...
 
void my_thread_end ()
 Deallocate memory used by the thread for book-keeping. More...
 
int my_errno ()
 Retrieve the MySQL thread-local storage variant of errno. More...
 
void set_my_errno (int my_errno)
 Set the MySQL thread-local storage variant of errno. More...
 
my_thread_id my_thread_var_id ()
 
void set_my_thread_var_id (my_thread_id id)
 
CODE_STATE ** my_thread_var_dbug ()
 

Variables

static bool my_thread_global_init_done = false
 
static uint THR_thread_count = 0
 
static Timeout_type my_thread_end_wait_time = 5
 
static my_thread_id thread_id = 0
 
static thread_local st_my_thread_varTHR_mysys = nullptr
 
static thread_local int THR_myerrno = 0
 
mysql_mutex_t THR_LOCK_myisam_mmap
 
mysql_mutex_t THR_LOCK_myisam
 
mysql_mutex_t THR_LOCK_heap
 
mysql_mutex_t THR_LOCK_malloc
 
mysql_mutex_t THR_LOCK_open
 
mysql_mutex_t THR_LOCK_lock
 
mysql_mutex_t THR_LOCK_net
 
mysql_mutex_t THR_LOCK_charset
 
mysql_mutex_t THR_LOCK_threads
 
mysql_cond_t THR_COND_threads
 

Detailed Description

Functions to handle initialization and allocation of all mysys & debug thread variables.

Function Documentation

◆ my_errno()

int my_errno ( )

Retrieve the MySQL thread-local storage variant of errno.

◆ my_thread_end()

void my_thread_end ( void  )

Deallocate memory used by the thread for book-keeping.

Note
This may be called multiple times for a thread. This happens for example when one calls 'mysql_server_init()' mysql_server_end() and then ends with a mysql_end().

◆ my_thread_global_end()

void my_thread_global_end ( )

◆ my_thread_global_init()

bool my_thread_global_init ( )

initialize thread environment

Return values
falseok
trueerror

◆ my_thread_global_reinit()

void my_thread_global_reinit ( )

Re-initialize components initialized early with my_thread_global_init.

Some mutexes were initialized before the instrumentation. Destroy + create them again, now that the instrumentation is in place. This is safe, since this function() is called before creating new threads, so the mutexes are not in use.

◆ my_thread_init()

bool my_thread_init ( void  )

Allocate thread specific memory for the thread, used by mysys and dbug.

Note
This function may called multiple times for a thread, for example if one uses my_init() followed by mysql_server_init().
Return values
falseok
trueFatal error; mysys/dbug functions can't be used

◆ my_thread_var_dbug()

CODE_STATE** my_thread_var_dbug ( )

◆ my_thread_var_id()

my_thread_id my_thread_var_id ( )

◆ mysys_thread_var()

static struct st_my_thread_var* mysys_thread_var ( )
static

◆ set_my_errno()

void set_my_errno ( int  my_errno)

Set the MySQL thread-local storage variant of errno.

◆ set_my_thread_var_id()

void set_my_thread_var_id ( my_thread_id  id)

◆ set_mysys_thread_var()

static int set_mysys_thread_var ( struct st_my_thread_var mysys_var)
static

Variable Documentation

◆ my_thread_end_wait_time

Timeout_type my_thread_end_wait_time = 5
static

◆ my_thread_global_init_done

bool my_thread_global_init_done = false
static

◆ THR_COND_threads

mysql_cond_t THR_COND_threads

◆ THR_LOCK_charset

mysql_mutex_t THR_LOCK_charset

◆ THR_LOCK_heap

mysql_mutex_t THR_LOCK_heap

◆ THR_LOCK_lock

mysql_mutex_t THR_LOCK_lock

◆ THR_LOCK_malloc

mysql_mutex_t THR_LOCK_malloc

◆ THR_LOCK_myisam

mysql_mutex_t THR_LOCK_myisam

◆ THR_LOCK_myisam_mmap

mysql_mutex_t THR_LOCK_myisam_mmap

◆ THR_LOCK_net

mysql_mutex_t THR_LOCK_net

◆ THR_LOCK_open

mysql_mutex_t THR_LOCK_open

◆ THR_LOCK_threads

mysql_mutex_t THR_LOCK_threads

◆ THR_myerrno

thread_local int THR_myerrno = 0
static

◆ THR_mysys

thread_local st_my_thread_var* THR_mysys = nullptr
static

◆ THR_thread_count

uint THR_thread_count = 0
static

◆ thread_id

my_thread_id thread_id = 0
static