MySQL 8.0.39
Source Code Documentation
sql_timer.cc File Reference
#include "sql/sql_timer.h"
#include <stddef.h>
#include <atomic>
#include "my_dbug.h"
#include "my_inttypes.h"
#include "my_macros.h"
#include "my_sys.h"
#include "my_thread_local.h"
#include "my_timer.h"
#include "mysql/components/services/bits/mysql_mutex_bits.h"
#include "mysql/psi/mysql_mutex.h"
#include "mysql/service_mysql_alloc.h"
#include "sql/mysqld.h"
#include "sql/mysqld_thd_manager.h"
#include "sql/psi_memory_key.h"
#include "sql/sql_class.h"
#include "thr_mutex.h"

Classes

struct  THD_timer_info
 

Macros

#define my_container_of(ptr, type, member)    ((type *)((char *)ptr - offsetof(type, member)))
 Cast a member of a structure to the structure that contains it. More...
 

Functions

static void timer_callback (my_timer_t *timer)
 Timer expiration notification callback. More...
 
static THD_timer_infothd_timer_create (void)
 Allocate and initialize a thread timer object. More...
 
static bool timer_notify (THD_timer_info *thd_timer)
 Notify a thread (session) that its timer has expired. More...
 
THD_timer_infothd_timer_set (THD *thd, THD_timer_info *thd_timer, unsigned long time)
 Set the time until the currently running statement is aborted. More...
 
static bool reap_timer (THD_timer_info *thd_timer, bool pending)
 Reap a (possibly) pending timer object. More...
 
THD_timer_infothd_timer_reset (THD_timer_info *thd_timer)
 Deactivate the given timer. More...
 
void thd_timer_destroy (THD_timer_info *thd_timer)
 Release resources allocated for a thread timer. More...
 

Macro Definition Documentation

◆ my_container_of

#define my_container_of (   ptr,
  type,
  member 
)     ((type *)((char *)ptr - offsetof(type, member)))

Cast a member of a structure to the structure that contains it.

Parameters
ptrPointer to the member.
typeType of the structure that contains the member.
memberName of the member within the structure.

Function Documentation

◆ reap_timer()

static bool reap_timer ( THD_timer_info thd_timer,
bool  pending 
)
static

Reap a (possibly) pending timer object.

Parameters
thd_timerThread timer object.
pendingState of the timer object. true if timer is not expired. false otherwise.
Returns
true if the timer object is unreachable.

◆ thd_timer_create()

static THD_timer_info * thd_timer_create ( void  )
static

Allocate and initialize a thread timer object.

Returns
NULL on failure.

◆ thd_timer_destroy()

void thd_timer_destroy ( THD_timer_info thd_timer)

Release resources allocated for a thread timer.

Parameters
thd_timerThread timer object.

◆ thd_timer_reset()

THD_timer_info * thd_timer_reset ( THD_timer_info thd_timer)

Deactivate the given timer.

Parameters
thd_timerThread timer object.
Returns
NULL if the timer object was orphaned. Otherwise, the given timer object is returned.

◆ thd_timer_set()

THD_timer_info * thd_timer_set ( THD thd,
THD_timer_info thd_timer,
unsigned long  time 
)

Set the time until the currently running statement is aborted.

Parameters
thdThread (session) context.
thd_timerThread timer object.
timeLength of time, in milliseconds, until the currently running statement is aborted.
Returns
NULL on failure.

◆ timer_callback()

static void timer_callback ( my_timer_t timer)
static

Timer expiration notification callback.

Parameters
timerTimer (mysys) object.
Note
Invoked in a separate thread of control.

◆ timer_notify()

static bool timer_notify ( THD_timer_info thd_timer)
static

Notify a thread (session) that its timer has expired.

Parameters
thd_timerThread timer object.
Returns
true if the object should be destroyed.