MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
service_thd_wait.h
Go to the documentation of this file.
1 /* Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
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 as published by
5  the Free Software Foundation; version 2 of the License.
6 
7  This program is distributed in the hope that it will be useful,
8  but WITHOUT ANY WARRANTY; without even the implied warranty of
9  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  GNU General Public License for more details.
11 
12  You should have received a copy of the GNU General Public License
13  along with this program; if not, write to the Free Software
14  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
15 
16 #ifndef MYSQL_SERVICE_THD_WAIT_INCLUDED
17 #define MYSQL_SERVICE_THD_WAIT_INCLUDED
18 
49 #ifdef __cplusplus
50 extern "C" {
51 #endif
52 
53 /*
54  One should only report wait events that could potentially block for a
55  long time. A mutex wait is too short of an event to report. The reason
56  is that an event which is reported leads to a new thread starts
57  executing a query and this has a negative impact of usage of CPU caches
58  and thus the expected gain of starting a new thread must be higher than
59  the expected cost of lost performance due to starting a new thread.
60 
61  Good examples of events that should be reported are waiting for row locks
62  that could easily be for many milliseconds or even seconds and the same
63  holds true for global read locks, table locks and other meta data locks.
64  Another event of interest is going to sleep for an extended time.
65 */
66 typedef enum _thd_wait_type_e {
67  THD_WAIT_SLEEP= 1,
68  THD_WAIT_DISKIO= 2,
69  THD_WAIT_ROW_LOCK= 3,
70  THD_WAIT_GLOBAL_LOCK= 4,
71  THD_WAIT_META_DATA_LOCK= 5,
72  THD_WAIT_TABLE_LOCK= 6,
73  THD_WAIT_USER_LOCK= 7,
74  THD_WAIT_BINLOG= 8,
75  THD_WAIT_GROUP_COMMIT= 9,
76  THD_WAIT_SYNC= 10,
77  THD_WAIT_LAST= 11
78 } thd_wait_type;
79 
80 extern struct thd_wait_service_st {
81  void (*thd_wait_begin_func)(MYSQL_THD, int);
82  void (*thd_wait_end_func)(MYSQL_THD);
83 } *thd_wait_service;
84 
85 #ifdef MYSQL_DYNAMIC_PLUGIN
86 
87 #define thd_wait_begin(_THD, _WAIT_TYPE) \
88  thd_wait_service->thd_wait_begin_func(_THD, _WAIT_TYPE)
89 #define thd_wait_end(_THD) thd_wait_service->thd_wait_end_func(_THD)
90 
91 #else
92 
93 void thd_wait_begin(MYSQL_THD thd, int wait_type);
94 void thd_wait_end(MYSQL_THD thd);
95 
96 #endif
97 
98 #ifdef __cplusplus
99 }
100 #endif
101 
102 #endif
103