MySQL 9.1.0
Source Code Documentation
my_thread.h File Reference

Defines to make different thread packages compatible. More...

#include <errno.h>
#include <stdbool.h>
#include <stddef.h>
#include <mysql/components/services/bits/my_thread_bits.h>
#include "my_compiler.h"
#include "my_config.h"
#include "my_inttypes.h"
#include "my_macros.h"

Go to the source code of this file.

Macros

#define ETIME   ETIMEDOUT /* For FreeBSD */
 
#define ETIMEDOUT   145 /* Win32 doesn't have this */
 
#define DEFAULT_THREAD_STACK   (1024UL * 1024UL)
 
#define MY_THREAD_CREATE_JOINABLE   PTHREAD_CREATE_JOINABLE
 
#define MY_THREAD_CREATE_DETACHED   PTHREAD_CREATE_DETACHED
 

Typedefs

typedef void *(* my_start_routine) (void *)
 

Functions

static bool is_timeout (int e)
 
static my_thread_t my_thread_self ()
 
static int my_thread_equal (my_thread_t t1, my_thread_t t2)
 
static int my_thread_attr_init (my_thread_attr_t *attr)
 
static int my_thread_attr_destroy (my_thread_attr_t *attr)
 
static int my_thread_attr_setstacksize (my_thread_attr_t *attr, size_t stacksize)
 
static int my_thread_attr_setdetachstate (my_thread_attr_t *attr, int detachstate)
 
static int my_thread_attr_getstacksize (my_thread_attr_t *attr, size_t *stacksize)
 
static void my_thread_yield ()
 
bool operator== (const my_thread_handle &a, const my_thread_handle &b)
 
bool operator!= (const my_thread_handle &a, const my_thread_handle &b)
 
int my_thread_create (my_thread_handle *thread, const my_thread_attr_t *attr, my_start_routine func, void *arg)
 
int my_thread_join (my_thread_handle *thread, void **value_ptr)
 
int my_thread_cancel (my_thread_handle *thread)
 
void my_thread_exit (void *value_ptr)
 
void my_thread_self_setname (const char *name)
 Sets the name of the thread for system and debugger, if possible. More...
 
bool my_thread_global_init ()
 initialize thread environment More...
 
void my_thread_global_reinit ()
 Re-initialize components initialized early with my_thread_global_init. 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...
 
bool my_thread_is_inited ()
 

Detailed Description

Defines to make different thread packages compatible.

Macro Definition Documentation

◆ DEFAULT_THREAD_STACK

#define DEFAULT_THREAD_STACK   (1024UL * 1024UL)

◆ ETIME

#define ETIME   ETIMEDOUT /* For FreeBSD */

◆ ETIMEDOUT

#define ETIMEDOUT   145 /* Win32 doesn't have this */

◆ MY_THREAD_CREATE_DETACHED

#define MY_THREAD_CREATE_DETACHED   PTHREAD_CREATE_DETACHED

◆ MY_THREAD_CREATE_JOINABLE

#define MY_THREAD_CREATE_JOINABLE   PTHREAD_CREATE_JOINABLE

Typedef Documentation

◆ my_start_routine

typedef void *(* my_start_routine) (void *)

Function Documentation

◆ is_timeout()

static bool is_timeout ( int  e)
inlinestatic

◆ my_thread_attr_destroy()

static int my_thread_attr_destroy ( my_thread_attr_t attr)
inlinestatic

◆ my_thread_attr_getstacksize()

static int my_thread_attr_getstacksize ( my_thread_attr_t attr,
size_t *  stacksize 
)
inlinestatic

◆ my_thread_attr_init()

static int my_thread_attr_init ( my_thread_attr_t attr)
inlinestatic

◆ my_thread_attr_setdetachstate()

static int my_thread_attr_setdetachstate ( my_thread_attr_t attr,
int  detachstate 
)
inlinestatic

◆ my_thread_attr_setstacksize()

static int my_thread_attr_setstacksize ( my_thread_attr_t attr,
size_t  stacksize 
)
inlinestatic

◆ my_thread_cancel()

int my_thread_cancel ( my_thread_handle thread)

◆ my_thread_create()

int my_thread_create ( my_thread_handle thread,
const my_thread_attr_t attr,
my_start_routine  func,
void *  arg 
)

◆ my_thread_end()

void my_thread_end ( )

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_equal()

static int my_thread_equal ( my_thread_t  t1,
my_thread_t  t2 
)
inlinestatic

◆ my_thread_exit()

void my_thread_exit ( void *  value_ptr)

◆ 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 ( )

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_is_inited()

bool my_thread_is_inited ( )

◆ my_thread_join()

int my_thread_join ( my_thread_handle thread,
void **  value_ptr 
)

◆ my_thread_self()

static my_thread_t my_thread_self ( )
inlinestatic

◆ my_thread_self_setname()

void my_thread_self_setname ( const char *  name)

Sets the name of the thread for system and debugger, if possible.

Parameters
nameName to set, must be shorter than SETNAME_MAX_LENGTH, including NULL character.

◆ my_thread_yield()

static void my_thread_yield ( )
inlinestatic

◆ operator!=()

bool operator!= ( const my_thread_handle a,
const my_thread_handle b 
)
inline

◆ operator==()

bool operator== ( const my_thread_handle a,
const my_thread_handle b 
)
inline