1 | /* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. |
2 | Copyright (c) 2017, MariaDB Corporation. |
3 | |
4 | This program is free software; you can redistribute it and/or modify |
5 | it under the terms of the GNU General Public License as published by |
6 | the Free Software Foundation; version 2 of the License. |
7 | |
8 | This program is distributed in the hope that it will be useful, |
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
11 | GNU General Public License for more details. |
12 | |
13 | You should have received a copy of the GNU General Public License |
14 | along with this program; if not, write to the Free Software Foundation, |
15 | 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */ |
16 | |
17 | #ifndef MYSQL_IDLE_H |
18 | #define MYSQL_IDLE_H |
19 | |
20 | /** |
21 | @file mysql/psi/mysql_idle.h |
22 | Instrumentation helpers for idle waits. |
23 | */ |
24 | |
25 | #include "mysql/psi/psi.h" |
26 | |
27 | /** |
28 | @defgroup Idle_instrumentation Idle Instrumentation |
29 | @ingroup Instrumentation_interface |
30 | @{ |
31 | */ |
32 | |
33 | /** |
34 | @def MYSQL_START_IDLE_WAIT |
35 | Instrumentation helper for table io_waits. |
36 | This instrumentation marks the start of a wait event. |
37 | @param LOCKER the locker |
38 | @param STATE the locker state |
39 | @sa MYSQL_END_IDLE_WAIT. |
40 | */ |
41 | #ifdef HAVE_PSI_IDLE_INTERFACE |
42 | #define MYSQL_START_IDLE_WAIT(LOCKER, STATE) \ |
43 | LOCKER= inline_mysql_start_idle_wait(STATE, __FILE__, __LINE__) |
44 | #else |
45 | #define MYSQL_START_IDLE_WAIT(LOCKER, STATE) \ |
46 | do {} while (0) |
47 | #endif |
48 | |
49 | /** |
50 | @def MYSQL_END_IDLE_WAIT |
51 | Instrumentation helper for idle waits. |
52 | This instrumentation marks the end of a wait event. |
53 | @param LOCKER the locker |
54 | @sa MYSQL_START_IDLE_WAIT. |
55 | */ |
56 | #ifdef HAVE_PSI_IDLE_INTERFACE |
57 | #define MYSQL_END_IDLE_WAIT(LOCKER) \ |
58 | inline_mysql_end_idle_wait(LOCKER) |
59 | #else |
60 | #define MYSQL_END_IDLE_WAIT(LOCKER) \ |
61 | do {} while (0) |
62 | #endif |
63 | |
64 | #ifdef HAVE_PSI_IDLE_INTERFACE |
65 | /** |
66 | Instrumentation calls for MYSQL_START_IDLE_WAIT. |
67 | @sa MYSQL_END_IDLE_WAIT. |
68 | */ |
69 | static inline struct PSI_idle_locker * |
70 | inline_mysql_start_idle_wait(PSI_idle_locker_state *state, |
71 | const char *src_file, uint src_line) |
72 | { |
73 | struct PSI_idle_locker *locker; |
74 | locker= PSI_IDLE_CALL(start_idle_wait)(state, src_file, src_line); |
75 | return locker; |
76 | } |
77 | |
78 | /** |
79 | Instrumentation calls for MYSQL_END_IDLE_WAIT. |
80 | @sa MYSQL_START_IDLE_WAIT. |
81 | */ |
82 | static inline void |
83 | inline_mysql_end_idle_wait(struct PSI_idle_locker *locker) |
84 | { |
85 | if (psi_likely(locker != NULL)) |
86 | PSI_IDLE_CALL(end_idle_wait)(locker); |
87 | } |
88 | #endif |
89 | |
90 | /** @} (end of group Idle_instrumentation) */ |
91 | |
92 | #endif |
93 | |
94 | |