Drizzled Public API Documentation

os0thread.h
Go to the documentation of this file.
00001 /*****************************************************************************
00002 
00003 Copyright (C) 1995, 2009, Innobase Oy. All Rights Reserved.
00004 
00005 This program is free software; you can redistribute it and/or modify it under
00006 the terms of the GNU General Public License as published by the Free Software
00007 Foundation; version 2 of the License.
00008 
00009 This program is distributed in the hope that it will be useful, but WITHOUT
00010 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00011 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
00012 
00013 You should have received a copy of the GNU General Public License along with
00014 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
00015 St, Fifth Floor, Boston, MA 02110-1301 USA
00016 
00017 *****************************************************************************/
00018 
00019 /**************************************************/
00027 #pragma once
00028 #ifndef os0thread_h
00029 #define os0thread_h
00030 
00031 #include "univ.i"
00032 
00033 /* Maximum number of threads which can be created in the program;
00034 this is also the size of the wait slot array for MySQL threads which
00035 can wait inside InnoDB */
00036 
00037 #define OS_THREAD_MAX_N   srv_max_n_threads
00038 
00039 
00040 /* Possible fixed priorities for threads */
00041 #define OS_THREAD_PRIORITY_NONE   100
00042 #define OS_THREAD_PRIORITY_BACKGROUND 1
00043 #define OS_THREAD_PRIORITY_NORMAL 2
00044 #define OS_THREAD_PRIORITY_ABOVE_NORMAL 3
00045 
00046 #ifdef __WIN__
00047 typedef void*     os_thread_t;
00048 typedef unsigned long   os_thread_id_t; 
00050 #else
00051 #include <pthread.h>
00052 typedef pthread_t   os_thread_t;
00053 typedef os_thread_t   os_thread_id_t; 
00056 #endif
00057 
00058 /* Define a function pointer type to use in a typecast */
00059 typedef void* (*os_posix_f_t) (void*);
00060 
00061 #ifdef HAVE_PSI_INTERFACE
00062 /* Define for performance schema registration key */
00063 typedef unsigned int    mysql_pfs_key_t;
00064 #endif
00065 
00066 /***************************************************************/
00069 UNIV_INTERN
00070 ibool
00071 os_thread_eq(
00072 /*=========*/
00073   os_thread_id_t  a,  
00074   os_thread_id_t  b); 
00075 /****************************************************************/
00079 UNIV_INTERN
00080 ulint
00081 os_thread_pf(
00082 /*=========*/
00083   os_thread_id_t  a); 
00084 /****************************************************************/
00091 UNIV_INTERN
00092 os_thread_t
00093 os_thread_create(
00094 /*=============*/
00095 #ifndef __WIN__
00096   os_posix_f_t    start_f,
00097 #else
00098   ulint (*start_f)(void*),    
00100 #endif
00101   void*     arg,    
00103   os_thread_id_t*   thread_id); 
00105 /*****************************************************************/
00107 UNIV_INTERN
00108 void
00109 os_thread_exit(
00110 /*===========*/
00111   void* exit_value);  
00113 /*****************************************************************/
00116 UNIV_INTERN
00117 os_thread_id_t
00118 os_thread_get_curr_id(void);
00119 /*========================*/
00120 /*****************************************************************/
00123 UNIV_INTERN
00124 os_thread_t
00125 os_thread_get_curr(void);
00126 /*====================*/
00127 /*****************************************************************/
00129 UNIV_INTERN
00130 void
00131 os_thread_yield(void);
00132 /*=================*/
00133 /*****************************************************************/
00135 UNIV_INTERN
00136 void
00137 os_thread_sleep(
00138 /*============*/
00139   ulint tm);  
00140 /******************************************************************/
00143 UNIV_INTERN
00144 ulint
00145 os_thread_get_priority(
00146 /*===================*/
00147   os_thread_t handle);
00148 /******************************************************************/
00150 UNIV_INTERN
00151 void
00152 os_thread_set_priority(
00153 /*===================*/
00154   os_thread_t handle, 
00155   ulint   pri); 
00156 /******************************************************************/
00159 UNIV_INTERN
00160 ulint
00161 os_thread_get_last_error(void);
00162 /*==========================*/
00163 
00164 #ifndef UNIV_NONINL
00165 #include "os0thread.ic"
00166 #endif
00167 
00168 #endif