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