MySQL 8.4.1
Source Code Documentation
mysql_idle.h
Go to the documentation of this file.
1/* Copyright (c) 2011, 2024, Oracle and/or its affiliates.
2
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License, version 2.0,
5 as published by the Free Software Foundation.
6
7 This program is designed to work with certain software (including
8 but not limited to OpenSSL) that is licensed under separate terms,
9 as designated in a particular file or component or in included license
10 documentation. The authors of MySQL hereby grant you an additional
11 permission to link the program and your derivative works with the
12 separately licensed software that they have either included with
13 the program or referenced in the documentation.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License, version 2.0, for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
23
24#ifndef MYSQL_IDLE_H
25#define MYSQL_IDLE_H
26
27/**
28 @file include/mysql/psi/mysql_idle.h
29 Instrumentation helpers for idle waits.
30*/
31
32/* HAVE_PSI_*_INTERFACE */
33#include "my_psi_config.h" // IWYU pragma: keep
34
35#include "mysql/psi/psi_idle.h"
36
37#if defined(MYSQL_SERVER) || defined(PFS_DIRECT_CALL)
38/* PSI_IDLE_CALL() as direct call. */
39#include "pfs_idle_provider.h" // IWYU pragma: keep
40#endif
41
42#ifndef PSI_IDLE_CALL
43#define PSI_IDLE_CALL(M) psi_idle_service->M
44#endif
45
46/**
47 @defgroup psi_api_idle Idle Instrumentation (API)
48 @ingroup psi_api
49 @{
50*/
51
52/**
53 @def MYSQL_START_IDLE_WAIT
54 Instrumentation helper for table io_waits.
55 This instrumentation marks the start of a wait event.
56 @param LOCKER the locker
57 @param STATE the locker state
58 @sa MYSQL_END_IDLE_WAIT.
59*/
60#ifdef HAVE_PSI_IDLE_INTERFACE
61#define MYSQL_START_IDLE_WAIT(LOCKER, STATE) \
62 LOCKER = inline_mysql_start_idle_wait(STATE, __FILE__, __LINE__)
63#else
64#define MYSQL_START_IDLE_WAIT(LOCKER, STATE) \
65 do { \
66 } while (0)
67#endif
68
69/**
70 @def MYSQL_END_IDLE_WAIT
71 Instrumentation helper for idle waits.
72 This instrumentation marks the end of a wait event.
73 @param LOCKER the locker
74 @sa MYSQL_START_IDLE_WAIT.
75*/
76#ifdef HAVE_PSI_IDLE_INTERFACE
77#define MYSQL_END_IDLE_WAIT(LOCKER) inline_mysql_end_idle_wait(LOCKER)
78#else
79#define MYSQL_END_IDLE_WAIT(LOCKER) \
80 do { \
81 } while (0)
82#endif
83
84#ifdef HAVE_PSI_IDLE_INTERFACE
85/**
86 Instrumentation calls for MYSQL_START_IDLE_WAIT.
87 @sa MYSQL_END_IDLE_WAIT.
88*/
90 PSI_idle_locker_state *state, const char *src_file, int src_line) {
91 struct PSI_idle_locker *locker;
92 locker = PSI_IDLE_CALL(start_idle_wait)(state, src_file, src_line);
93 return locker;
94}
95
96/**
97 Instrumentation calls for MYSQL_END_IDLE_WAIT.
98 @sa MYSQL_START_IDLE_WAIT.
99*/
100static inline void inline_mysql_end_idle_wait(struct PSI_idle_locker *locker) {
101 if (likely(locker != nullptr)) {
102 PSI_IDLE_CALL(end_idle_wait)(locker);
103 }
104}
105#endif
106
107/** @} (end of group psi_api_idle) */
108
109#endif
#define PSI_IDLE_CALL(M)
Definition: psi_idle.h:36
struct PSI_idle_locker PSI_idle_locker
Definition: psi_idle_bits.h:41
static void inline_mysql_end_idle_wait(struct PSI_idle_locker *locker)
Instrumentation calls for MYSQL_END_IDLE_WAIT.
Definition: mysql_idle.h:100
static struct PSI_idle_locker * inline_mysql_start_idle_wait(PSI_idle_locker_state *state, const char *src_file, int src_line)
Instrumentation calls for MYSQL_START_IDLE_WAIT.
Definition: mysql_idle.h:89
constexpr bool likely(bool expr)
Definition: my_compiler.h:57
Defines various enable/disable and HAVE_ macros related to the performance schema instrumentation sys...
Performance schema instrumentation (declarations).
Performance schema instrumentation interface.
State data storage for start_idle_wait_v1_t.
Definition: psi_idle_bits.h:52