MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
scheduler.h
1 #ifndef SCHEDULER_INCLUDED
2 #define SCHEDULER_INCLUDED
3 
4 /* Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; version 2 of the License.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program; if not, write to the Free Software Foundation,
17  51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
18 
19 /*
20  Classes for the thread scheduler
21 */
22 
23 class THD;
24 
25 /* Functions used when manipulating threads */
26 
28 {
29  uint max_threads;
30  bool (*init)(void);
31  bool (*init_new_connection_thread)(void);
32  void (*add_connection)(THD *thd);
33  void (*thd_wait_begin)(THD *thd, int wait_type);
34  void (*thd_wait_end)(THD *thd);
35  void (*post_kill_notification)(THD *thd);
36  bool (*end_thread)(THD *thd, bool cache_thread);
37  void (*end)(void);
38 };
39 
40 
54 enum scheduler_types
55 {
56  /*
57  The default of --thread-handling is the first one in the
58  thread_handling_names array, this array has to be consistent with
59  the order in this array, so to change default one has to change
60  the first entry in this enum and the first entry in the
61  thread_handling_names array.
62  */
63  SCHEDULER_ONE_THREAD_PER_CONNECTION=0,
64  SCHEDULER_NO_THREADS,
65  SCHEDULER_TYPES_COUNT
66 };
67 
68 void one_thread_per_connection_scheduler();
69 void one_thread_scheduler();
70 
71 /*
72  To be used for pool-of-threads (implemeneted differently on various OSs)
73 */
75 {
76 public:
77  /*
78  Thread instrumentation for the user job.
79  This member holds the instrumentation while the user job is not run
80  by a thread.
81 
82  Note that this member is not conditionally declared
83  (ifdef HAVE_PSI_INTERFACE), because doing so will change the binary
84  layout of THD, which is exposed to plugin code that may be compiled
85  differently.
86  */
87  PSI_thread *m_psi;
88 
89  void *data; /* scheduler-specific data structure */
90 
91  thd_scheduler();
92  ~thd_scheduler();
93 };
94 
95 void *thd_get_scheduler_data(THD *thd);
96 void thd_set_scheduler_data(THD *thd, void *data);
97 PSI_thread* thd_get_psi(THD *thd);
98 void thd_set_psi(THD *thd, PSI_thread *psi);
99 
100 extern scheduler_functions *thread_scheduler;
101 
102 #endif