InnoDB Plugin  1.0
os0thread.h
Go to the documentation of this file.
1 /*****************************************************************************
2 
3 Copyright (c) 1995, 2011, Oracle and/or its affiliates. All Rights Reserved.
4 
5 This program is free software; you can redistribute it and/or modify it under
6 the terms of the GNU General Public License as published by the Free Software
7 Foundation; version 2 of the License.
8 
9 This program is distributed in the hope that it will be useful, but WITHOUT
10 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12 
13 You should have received a copy of the GNU General Public License along with
14 this program; if not, write to the Free Software Foundation, Inc.,
15 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
16 
17 *****************************************************************************/
18 
19 /**************************************************/
27 #ifndef os0thread_h
28 #define os0thread_h
29 
30 #include "univ.i"
31 
32 /* Maximum number of threads which can be created in the program;
33 this is also the size of the wait slot array for MySQL threads which
34 can wait inside InnoDB */
35 
36 #define OS_THREAD_MAX_N srv_max_n_threads
37 
38 /* Possible fixed priorities for threads */
39 #define OS_THREAD_PRIORITY_NONE 100
40 #define OS_THREAD_PRIORITY_BACKGROUND 1
41 #define OS_THREAD_PRIORITY_NORMAL 2
42 #define OS_THREAD_PRIORITY_ABOVE_NORMAL 3
43 
44 #ifdef __WIN__
45 typedef void* os_thread_t;
46 typedef DWORD os_thread_id_t;
48 extern "C" {
49 typedef LPTHREAD_START_ROUTINE os_thread_func_t;
50 }
51 
53 #define DECLARE_THREAD(func) WINAPI func
54 
59 #define os_thread_create(f,a,i) \
60  os_thread_create_func(reinterpret_cast<os_thread_func_t>(f), a, i)
61 
62 #else
63 
64 typedef pthread_t os_thread_t;
65 typedef os_thread_t os_thread_id_t;
68 extern "C" { typedef void* (*os_thread_func_t)(void*); }
69 
71 #define DECLARE_THREAD(func) func
72 #define os_thread_create(f,a,i) os_thread_create_func(f, a, i)
73 
74 #endif /* __WIN__ */
75 
76 /* Define a function pointer type to use in a typecast */
77 typedef void* (*os_posix_f_t) (void*);
78 
79 #ifdef HAVE_PSI_INTERFACE
80 /* Define for performance schema registration key */
81 typedef unsigned int mysql_pfs_key_t;
82 #endif
83 
84 /***************************************************************/
87 UNIV_INTERN
88 ibool
90 /*=========*/
91  os_thread_id_t a,
92  os_thread_id_t b);
93 /****************************************************************/
97 UNIV_INTERN
98 ulint
100 /*=========*/
101  os_thread_id_t a);
102 /****************************************************************/
109 UNIV_INTERN
110 os_thread_t
112 /*==================*/
113  os_thread_func_t func,
115  void* arg,
117  os_thread_id_t* thread_id);
120 /*****************************************************************/
122 UNIV_INTERN
123 void
125 /*===========*/
126  void* exit_value)
128  UNIV_COLD __attribute__((noreturn));
129 /*****************************************************************/
132 UNIV_INTERN
135 /*========================*/
136 /*****************************************************************/
138 UNIV_INTERN
139 void
140 os_thread_yield(void);
141 /*=================*/
142 /*****************************************************************/
144 UNIV_INTERN
145 void
147 /*============*/
148  ulint tm);
150 #ifndef UNIV_NONINL
151 #include "os0thread.ic"
152 #endif
153 
154 #endif