~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/innobase/thr/thr0loc.c

  • Committer: Brian Aker
  • Date: 2009-04-07 06:38:05 UTC
  • mfrom: (975.1.3 merge)
  • Revision ID: brian@gaz-20090407063805-vd0t7tim8vxkqz4j
Merge of session lock removal

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
*****************************************************************************/
18
18
 
19
 
/**************************************************//**
20
 
@file thr/thr0loc.c
 
19
/******************************************************
21
20
The thread local storage
22
21
 
23
22
Created 10/5/1995 Heikki Tuuri
44
43
the thread local storage, just add it to struct thr_local_struct in the
45
44
header file. */
46
45
 
47
 
/** Mutex protecting thr_local_hash */
 
46
/* Mutex protecting the local storage hash table */
48
47
static mutex_t          thr_local_mutex;
49
48
 
50
 
/** The hash table. The module is not yet initialized when it is NULL. */
 
49
/* The hash table. The module is not yet initialized when it is NULL. */
51
50
static hash_table_t*    thr_local_hash  = NULL;
52
51
 
53
 
/** Thread local data */
54
 
typedef struct thr_local_struct thr_local_t;
55
 
 
56
 
/** @brief Thread local data.
57
 
The private data for each thread should be put to
 
52
/* The private data for each thread should be put to
58
53
the structure below and the accessor functions written
59
54
for the field. */
 
55
typedef struct thr_local_struct thr_local_t;
 
56
 
60
57
struct thr_local_struct{
61
 
        os_thread_id_t  id;     /*!< id of the thread which owns this struct */
62
 
        os_thread_t     handle; /*!< operating system handle to the thread */
63
 
        ulint           slot_no;/*!< the index of the slot in the thread table
 
58
        os_thread_id_t  id;     /* id of the thread which owns this struct */
 
59
        os_thread_t     handle; /* operating system handle to the thread */
 
60
        ulint           slot_no;/* the index of the slot in the thread table
64
61
                                for this thread */
65
 
        ibool           in_ibuf;/*!< TRUE if the the thread is doing an ibuf
 
62
        ibool           in_ibuf;/* TRUE if the the thread is doing an ibuf
66
63
                                operation */
67
 
        hash_node_t     hash;   /*!< hash chain node */
68
 
        ulint           magic_n;/*!< magic number (THR_LOCAL_MAGIC_N) */
 
64
        hash_node_t     hash;   /* hash chain node */
 
65
        ulint           magic_n;
69
66
};
70
67
 
71
 
/** The value of thr_local_struct::magic_n */
72
68
#define THR_LOCAL_MAGIC_N       1231234
73
69
 
74
 
/*******************************************************************//**
75
 
Returns the local storage struct for a thread.
76
 
@return local storage */
 
70
/***********************************************************************
 
71
Returns the local storage struct for a thread. */
77
72
static
78
73
thr_local_t*
79
74
thr_local_get(
80
75
/*==========*/
81
 
        os_thread_id_t  id)     /*!< in: thread id of the thread */
 
76
                                /* out: local storage */
 
77
        os_thread_id_t  id)     /* in: thread id of the thread */
82
78
{
83
79
        thr_local_t*    local;
84
80
 
107
103
        return(local);
108
104
}
109
105
 
110
 
/*******************************************************************//**
111
 
Gets the slot number in the thread table of a thread.
112
 
@return slot number */
 
106
/***********************************************************************
 
107
Gets the slot number in the thread table of a thread. */
113
108
UNIV_INTERN
114
109
ulint
115
110
thr_local_get_slot_no(
116
111
/*==================*/
117
 
        os_thread_id_t  id)     /*!< in: thread id of the thread */
 
112
                                /* out: slot number */
 
113
        os_thread_id_t  id)     /* in: thread id of the thread */
118
114
{
119
115
        ulint           slot_no;
120
116
        thr_local_t*    local;
130
126
        return(slot_no);
131
127
}
132
128
 
133
 
/*******************************************************************//**
 
129
/***********************************************************************
134
130
Sets the slot number in the thread table of a thread. */
135
131
UNIV_INTERN
136
132
void
137
133
thr_local_set_slot_no(
138
134
/*==================*/
139
 
        os_thread_id_t  id,     /*!< in: thread id of the thread */
140
 
        ulint           slot_no)/*!< in: slot number */
 
135
        os_thread_id_t  id,     /* in: thread id of the thread */
 
136
        ulint           slot_no)/* in: slot number */
141
137
{
142
138
        thr_local_t*    local;
143
139
 
150
146
        mutex_exit(&thr_local_mutex);
151
147
}
152
148
 
153
 
/*******************************************************************//**
 
149
/***********************************************************************
154
150
Returns pointer to the 'in_ibuf' field within the current thread local
155
 
storage.
156
 
@return pointer to the in_ibuf field */
 
151
storage. */
157
152
UNIV_INTERN
158
153
ibool*
159
154
thr_local_get_in_ibuf_field(void)
160
155
/*=============================*/
 
156
                        /* out: pointer to the in_ibuf field */
161
157
{
162
158
        thr_local_t*    local;
163
159
 
170
166
        return(&(local->in_ibuf));
171
167
}
172
168
 
173
 
/*******************************************************************//**
 
169
/***********************************************************************
174
170
Creates a local storage struct for the calling new thread. */
175
171
UNIV_INTERN
176
172
void
200
196
        mutex_exit(&thr_local_mutex);
201
197
}
202
198
 
203
 
/*******************************************************************//**
 
199
/***********************************************************************
204
200
Frees the local storage struct for the specified thread. */
205
201
UNIV_INTERN
206
202
void
207
203
thr_local_free(
208
204
/*===========*/
209
 
        os_thread_id_t  id)     /*!< in: thread id */
 
205
        os_thread_id_t  id)     /* in: thread id */
210
206
{
211
207
        thr_local_t*    local;
212
208
 
232
228
        mem_free(local);
233
229
}
234
230
 
235
 
/****************************************************************//**
 
231
/********************************************************************
236
232
Initializes the thread local storage module. */
237
233
UNIV_INTERN
238
234
void