1 | /***************************************************************************** |
2 | |
3 | Copyright (c) 2011, 2014, Oracle and/or its affiliates. All Rights Reserved. |
4 | Copyright (c) 2018, MariaDB Corporation. |
5 | |
6 | Portions of this file contain modifications contributed and copyrighted by |
7 | Google, Inc. Those modifications are gratefully acknowledged and are described |
8 | briefly in the InnoDB documentation. The contributions by Google are |
9 | incorporated with their permission, and subject to the conditions contained in |
10 | the file COPYING.Google. |
11 | |
12 | Portions of this file contain modifications contributed and copyrighted |
13 | by Percona Inc.. Those modifications are |
14 | gratefully acknowledged and are described briefly in the InnoDB |
15 | documentation. The contributions by Percona Inc. are incorporated with |
16 | their permission, and subject to the conditions contained in the file |
17 | COPYING.Percona. |
18 | |
19 | This program is free software; you can redistribute it and/or modify it under |
20 | the terms of the GNU General Public License as published by the Free Software |
21 | Foundation; version 2 of the License. |
22 | |
23 | This program is distributed in the hope that it will be useful, but WITHOUT |
24 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
25 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
26 | |
27 | You should have received a copy of the GNU General Public License along with |
28 | this program; if not, write to the Free Software Foundation, Inc., |
29 | 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA |
30 | |
31 | *****************************************************************************/ |
32 | |
33 | /**************************************************//** |
34 | @file srv/srv0conc.h |
35 | |
36 | InnoDB concurrency manager header file |
37 | |
38 | Created 2011/04/18 Sunny Bains |
39 | *******************************************************/ |
40 | |
41 | #ifndef srv_conc_h |
42 | #define srv_conc_h |
43 | |
44 | /** We are prepared for a situation that we have this many threads waiting for |
45 | a semaphore inside InnoDB. srv_start() sets the value. */ |
46 | extern ulint srv_max_n_threads; |
47 | |
48 | /** The following controls how many threads we let inside InnoDB concurrently: |
49 | threads waiting for locks are not counted into the number because otherwise |
50 | we could get a deadlock. Value of 0 will disable the concurrency check. */ |
51 | |
52 | extern ulong srv_thread_concurrency; |
53 | |
54 | struct row_prebuilt_t; |
55 | /*********************************************************************//** |
56 | Puts an OS thread to wait if there are too many concurrent threads |
57 | (>= srv_thread_concurrency) inside InnoDB. The threads wait in a FIFO queue. |
58 | @param[in,out] prebuilt row prebuilt handler */ |
59 | void |
60 | srv_conc_enter_innodb( |
61 | row_prebuilt_t* prebuilt); |
62 | |
63 | /*********************************************************************//** |
64 | This lets a thread enter InnoDB regardless of the number of threads inside |
65 | InnoDB. This must be called when a thread ends a lock wait. */ |
66 | void |
67 | srv_conc_force_enter_innodb( |
68 | /*========================*/ |
69 | trx_t* trx); /*!< in: transaction object associated with |
70 | the thread */ |
71 | |
72 | /*********************************************************************//** |
73 | This must be called when a thread exits InnoDB in a lock wait or at the |
74 | end of an SQL statement. */ |
75 | void |
76 | srv_conc_force_exit_innodb( |
77 | /*=======================*/ |
78 | trx_t* trx); /*!< in: transaction object associated with |
79 | the thread */ |
80 | |
81 | /*********************************************************************//** |
82 | Get the count of threads waiting inside InnoDB. */ |
83 | ulint |
84 | srv_conc_get_waiting_threads(void); |
85 | /*==============================*/ |
86 | |
87 | /*********************************************************************//** |
88 | Get the count of threads active inside InnoDB. */ |
89 | ulint |
90 | srv_conc_get_active_threads(void); |
91 | /*==============================*/ |
92 | |
93 | #endif /* srv_conc_h */ |
94 | |