~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: Monty Taylor
  • Date: 2009-02-08 10:59:43 UTC
  • mto: This revision was merged to the branch mainline in revision 852.
  • Revision ID: mordred@inaugust.com-20090208105943-e30tagctq2nrghxi
Renamed my_net_* to drizzleclient_net_* to help with namespace issues.

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
 
1
/******************************************************
21
2
The interface to the operating system
22
3
process and thread control primitives
23
4
 
 
5
(c) 1995 Innobase Oy
 
6
 
24
7
Created 9/8/1995 Heikki Tuuri
25
8
*******************************************************/
26
9
 
44
27
 
45
28
#ifdef __WIN__
46
29
typedef void*                   os_thread_t;
47
 
typedef unsigned long           os_thread_id_t; /*!< In Windows the thread id
 
30
typedef ulint                   os_thread_id_t; /* In Windows the thread id
48
31
                                                is an unsigned long int */
49
32
#else
50
 
#include <pthread.h>
51
33
typedef pthread_t               os_thread_t;
52
 
typedef os_thread_t             os_thread_id_t; /*!< In Unix we use the thread
 
34
typedef os_thread_t             os_thread_id_t; /* In Unix we use the thread
53
35
                                                handle itself as the id of
54
36
                                                the thread */
55
37
#endif
57
39
/* Define a function pointer type to use in a typecast */
58
40
typedef void* (*os_posix_f_t) (void*);
59
41
 
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 */
 
42
/*******************************************************************
 
43
Compares two thread ids for equality. */
68
44
UNIV_INTERN
69
45
ibool
70
46
os_thread_eq(
71
47
/*=========*/
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
 
/****************************************************************//**
 
48
                                /* out: TRUE if equal */
 
49
        os_thread_id_t  a,      /* in: OS thread or thread id */
 
50
        os_thread_id_t  b);     /* in: OS thread or thread id */
 
51
/********************************************************************
75
52
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 */
 
53
unique for the thread though! */
78
54
UNIV_INTERN
79
55
ulint
80
56
os_thread_pf(
81
57
/*=========*/
82
 
        os_thread_id_t  a);     /*!< in: OS thread identifier */
83
 
/****************************************************************//**
 
58
                                /* out: unsigned long int */
 
59
        os_thread_id_t  a);     /* in: thread or thread id */
 
60
/********************************************************************
84
61
Creates a new thread of execution. The execution starts from
85
62
the function given. The start function takes a void* parameter
86
63
and returns a ulint.
87
64
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 */
 
65
thread should always use that to exit and not use return() to exit. */
90
66
UNIV_INTERN
91
67
os_thread_t
92
68
os_thread_create(
93
69
/*=============*/
 
70
                                                /* out: handle to the thread */
94
71
#ifndef __WIN__
95
 
        os_posix_f_t            start_f,
 
72
                 os_posix_f_t            start_f,
96
73
#else
97
 
        ulint (*start_f)(void*),                /*!< in: pointer to function
 
74
        ulint (*start_f)(void*),                /* in: pointer to function
98
75
                                                from which to start */
99
76
#endif
100
 
        void*                   arg,            /*!< in: argument to start
 
77
        void*                   arg,            /* in: argument to start
101
78
                                                function */
102
 
        os_thread_id_t*         thread_id);     /*!< out: id of the created
 
79
        os_thread_id_t*         thread_id);     /* out: id of the created
103
80
                                                thread, or NULL */
104
81
 
105
 
/*****************************************************************//**
 
82
/*********************************************************************
106
83
Exits the current thread. */
107
84
UNIV_INTERN
108
85
void
109
86
os_thread_exit(
110
87
/*===========*/
111
 
        void*   exit_value);    /*!< in: exit value; in Windows this void*
 
88
        void*   exit_value);    /* in: exit value; in Windows this void*
112
89
                                is cast as a DWORD */
113
 
/*****************************************************************//**
114
 
Returns the thread identifier of current thread.
115
 
@return current thread identifier */
 
90
/*********************************************************************
 
91
Returns the thread identifier of current thread. */
116
92
UNIV_INTERN
117
93
os_thread_id_t
118
94
os_thread_get_curr_id(void);
119
95
/*========================*/
120
 
/*****************************************************************//**
121
 
Returns handle to the current thread.
122
 
@return current thread handle */
 
96
/*********************************************************************
 
97
Returns handle to the current thread. */
123
98
UNIV_INTERN
124
99
os_thread_t
125
100
os_thread_get_curr(void);
126
101
/*====================*/
127
 
/*****************************************************************//**
 
102
/*********************************************************************
128
103
Advises the os to give up remainder of the thread's time slice. */
129
104
UNIV_INTERN
130
105
void
131
106
os_thread_yield(void);
132
107
/*=================*/
133
 
/*****************************************************************//**
 
108
/*********************************************************************
134
109
The thread sleeps at least the time given in microseconds. */
135
110
UNIV_INTERN
136
111
void
137
112
os_thread_sleep(
138
113
/*============*/
139
 
        ulint   tm);    /*!< in: time in microseconds */
140
 
/******************************************************************//**
141
 
Gets a thread priority.
142
 
@return priority */
 
114
        ulint   tm);    /* in: time in microseconds */
 
115
/**********************************************************************
 
116
Gets a thread priority. */
143
117
UNIV_INTERN
144
118
ulint
145
119
os_thread_get_priority(
146
120
/*===================*/
147
 
        os_thread_t     handle);/*!< in: OS handle to the thread */
148
 
/******************************************************************//**
 
121
                                /* out: priority */
 
122
        os_thread_t     handle);/* in: OS handle to the thread */
 
123
/**********************************************************************
149
124
Sets a thread priority. */
150
125
UNIV_INTERN
151
126
void
152
127
os_thread_set_priority(
153
128
/*===================*/
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 */
 
129
        os_thread_t     handle, /* in: OS handle to the thread */
 
130
        ulint           pri);   /* in: priority: one of OS_PRIORITY_... */
 
131
/**********************************************************************
 
132
Gets the last operating system error code for the calling thread. */
159
133
UNIV_INTERN
160
134
ulint
161
135
os_thread_get_last_error(void);