MySQL 8.0.30
Source Code Documentation
mysql_idle.h
Go to the documentation of this file.
1/* Copyright (c) 2011, 2022, 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 also distributed 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 included with MySQL.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License, version 2.0, for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
22
23#ifndef MYSQL_IDLE_H
24#define MYSQL_IDLE_H
25
26/**
27 @file include/mysql/psi/mysql_idle.h
28 Instrumentation helpers for idle waits.
29*/
30
31/* HAVE_PSI_*_INTERFACE */
32#include "my_psi_config.h" // IWYU pragma: keep
33
34#include "mysql/psi/psi_idle.h"
35
36#if defined(MYSQL_SERVER) || defined(PFS_DIRECT_CALL)
37/* PSI_IDLE_CALL() as direct call. */
38#include "pfs_idle_provider.h" // IWYU pragma: keep
39#endif
40
41#ifndef PSI_IDLE_CALL
42#define PSI_IDLE_CALL(M) psi_idle_service->M
43#endif
44
45/**
46 @defgroup psi_api_idle Idle Instrumentation (API)
47 @ingroup psi_api
48 @{
49*/
50
51/**
52 @def MYSQL_START_IDLE_WAIT
53 Instrumentation helper for table io_waits.
54 This instrumentation marks the start of a wait event.
55 @param LOCKER the locker
56 @param STATE the locker state
57 @sa MYSQL_END_IDLE_WAIT.
58*/
59#ifdef HAVE_PSI_IDLE_INTERFACE
60#define MYSQL_START_IDLE_WAIT(LOCKER, STATE) \
61 LOCKER = inline_mysql_start_idle_wait(STATE, __FILE__, __LINE__)
62#else
63#define MYSQL_START_IDLE_WAIT(LOCKER, STATE) \
64 do { \
65 } while (0)
66#endif
67
68/**
69 @def MYSQL_END_IDLE_WAIT
70 Instrumentation helper for idle waits.
71 This instrumentation marks the end of a wait event.
72 @param LOCKER the locker
73 @sa MYSQL_START_IDLE_WAIT.
74*/
75#ifdef HAVE_PSI_IDLE_INTERFACE
76#define MYSQL_END_IDLE_WAIT(LOCKER) inline_mysql_end_idle_wait(LOCKER)
77#else
78#define MYSQL_END_IDLE_WAIT(LOCKER) \
79 do { \
80 } while (0)
81#endif
82
83#ifdef HAVE_PSI_IDLE_INTERFACE
84/**
85 Instrumentation calls for MYSQL_START_IDLE_WAIT.
86 @sa MYSQL_END_IDLE_WAIT.
87*/
89 PSI_idle_locker_state *state, const char *src_file, int src_line) {
90 struct PSI_idle_locker *locker;
91 locker = PSI_IDLE_CALL(start_idle_wait)(state, src_file, src_line);
92 return locker;
93}
94
95/**
96 Instrumentation calls for MYSQL_END_IDLE_WAIT.
97 @sa MYSQL_START_IDLE_WAIT.
98*/
99static inline void inline_mysql_end_idle_wait(struct PSI_idle_locker *locker) {
100 if (likely(locker != nullptr)) {
101 PSI_IDLE_CALL(end_idle_wait)(locker);
102 }
103}
104#endif
105
106/** @} (end of group psi_api_idle) */
107
108#endif
#define PSI_IDLE_CALL(M)
Definition: psi_idle.h:35
struct PSI_idle_locker PSI_idle_locker
Definition: psi_idle_bits.h:40
static void inline_mysql_end_idle_wait(struct PSI_idle_locker *locker)
Instrumentation calls for MYSQL_END_IDLE_WAIT.
Definition: mysql_idle.h:99
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:88
constexpr bool likely(bool expr)
Definition: my_compiler.h:54
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:51