~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/innobase/include/os0thread.h

  • Committer: Patrick Galbraith
  • Date: 2009-10-08 22:42:05 UTC
  • mto: (1166.5.3 memcached_functions)
  • mto: This revision was merged to the branch mainline in revision 1189.
  • Revision ID: patg@patrick-galbraiths-macbook-pro.local-20091008224205-gq1pehjsivvx0qo9
Starting over with a fresh tree, moved in memcached functions.

Memcached Functions for Drizzle. 

All tests pass.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*****************************************************************************
2
 
 
3
 
Copyright (c) 1995, 2009, Innobase Oy. 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., 51 Franklin
15
 
St, Fifth Floor, Boston, MA 02110-1301 USA
16
 
 
17
 
*****************************************************************************/
18
 
 
19
 
/**************************************************//**
20
 
@file include/os0thread.h
21
 
The interface to the operating system
22
 
process and thread control primitives
23
 
 
24
 
Created 9/8/1995 Heikki Tuuri
25
 
*******************************************************/
26
 
 
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
 
 
39
 
/* Possible fixed priorities for threads */
40
 
#define OS_THREAD_PRIORITY_NONE         100
41
 
#define OS_THREAD_PRIORITY_BACKGROUND   1
42
 
#define OS_THREAD_PRIORITY_NORMAL       2
43
 
#define OS_THREAD_PRIORITY_ABOVE_NORMAL 3
44
 
 
45
 
#ifdef __WIN__
46
 
typedef void*                   os_thread_t;
47
 
typedef unsigned long           os_thread_id_t; /*!< In Windows the thread id
48
 
                                                is an unsigned long int */
49
 
#else
50
 
#include <pthread.h>
51
 
typedef pthread_t               os_thread_t;
52
 
typedef os_thread_t             os_thread_id_t; /*!< In Unix we use the thread
53
 
                                                handle itself as the id of
54
 
                                                the thread */
55
 
#endif
56
 
 
57
 
/* Define a function pointer type to use in a typecast */
58
 
typedef void* (*os_posix_f_t) (void*);
59
 
 
60
 
#ifdef HAVE_PSI_INTERFACE
61
 
/* Define for performance schema registration key */
62
 
typedef unsigned int    mysql_pfs_key_t;
63
 
#endif
64
 
 
65
 
/***************************************************************//**
66
 
Compares two thread ids for equality.
67
 
@return TRUE if equal */
68
 
UNIV_INTERN
69
 
ibool
70
 
os_thread_eq(
71
 
/*=========*/
72
 
        os_thread_id_t  a,      /*!< in: OS thread or thread id */
73
 
        os_thread_id_t  b);     /*!< in: OS thread or thread id */
74
 
/****************************************************************//**
75
 
Converts an OS thread id to a ulint. It is NOT guaranteed that the ulint is
76
 
unique for the thread though!
77
 
@return thread identifier as a number */
78
 
UNIV_INTERN
79
 
ulint
80
 
os_thread_pf(
81
 
/*=========*/
82
 
        os_thread_id_t  a);     /*!< in: OS thread identifier */
83
 
/****************************************************************//**
84
 
Creates a new thread of execution. The execution starts from
85
 
the function given. The start function takes a void* parameter
86
 
and returns a ulint.
87
 
NOTE: We count the number of threads in os_thread_exit(). A created
88
 
thread should always use that to exit and not use return() to exit.
89
 
@return handle to the thread */
90
 
UNIV_INTERN
91
 
os_thread_t
92
 
os_thread_create(
93
 
/*=============*/
94
 
#ifndef __WIN__
95
 
        os_posix_f_t            start_f,
96
 
#else
97
 
        ulint (*start_f)(void*),                /*!< in: pointer to function
98
 
                                                from which to start */
99
 
#endif
100
 
        void*                   arg,            /*!< in: argument to start
101
 
                                                function */
102
 
        os_thread_id_t*         thread_id);     /*!< out: id of the created
103
 
                                                thread, or NULL */
104
 
 
105
 
/*****************************************************************//**
106
 
Exits the current thread. */
107
 
UNIV_INTERN
108
 
void
109
 
os_thread_exit(
110
 
/*===========*/
111
 
        void*   exit_value);    /*!< in: exit value; in Windows this void*
112
 
                                is cast as a DWORD */
113
 
/*****************************************************************//**
114
 
Returns the thread identifier of current thread.
115
 
@return current thread identifier */
116
 
UNIV_INTERN
117
 
os_thread_id_t
118
 
os_thread_get_curr_id(void);
119
 
/*========================*/
120
 
/*****************************************************************//**
121
 
Returns handle to the current thread.
122
 
@return current thread handle */
123
 
UNIV_INTERN
124
 
os_thread_t
125
 
os_thread_get_curr(void);
126
 
/*====================*/
127
 
/*****************************************************************//**
128
 
Advises the os to give up remainder of the thread's time slice. */
129
 
UNIV_INTERN
130
 
void
131
 
os_thread_yield(void);
132
 
/*=================*/
133
 
/*****************************************************************//**
134
 
The thread sleeps at least the time given in microseconds. */
135
 
UNIV_INTERN
136
 
void
137
 
os_thread_sleep(
138
 
/*============*/
139
 
        ulint   tm);    /*!< in: time in microseconds */
140
 
/******************************************************************//**
141
 
Gets a thread priority.
142
 
@return priority */
143
 
UNIV_INTERN
144
 
ulint
145
 
os_thread_get_priority(
146
 
/*===================*/
147
 
        os_thread_t     handle);/*!< in: OS handle to the thread */
148
 
/******************************************************************//**
149
 
Sets a thread priority. */
150
 
UNIV_INTERN
151
 
void
152
 
os_thread_set_priority(
153
 
/*===================*/
154
 
        os_thread_t     handle, /*!< in: OS handle to the thread */
155
 
        ulint           pri);   /*!< in: priority: one of OS_PRIORITY_... */
156
 
/******************************************************************//**
157
 
Gets the last operating system error code for the calling thread.
158
 
@return last error on Windows, 0 otherwise */
159
 
UNIV_INTERN
160
 
ulint
161
 
os_thread_get_last_error(void);
162
 
/*==========================*/
163
 
 
164
 
#ifndef UNIV_NONINL
165
 
#include "os0thread.ic"
166
 
#endif
167
 
 
168
 
#endif