~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: Brian Aker
  • Date: 2010-04-05 23:46:43 UTC
  • Revision ID: brian@gaz-20100405234643-0he3xnj902rc70r8
Fixing tests to work with PBXT.

Show diffs side-by-side

added added

removed removed

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