#include "thr0loc.h"#include "sync0sync.h"#include "hash0hash.h"#include "mem0mem.h"#include "srv0srv.h"Include dependency graph for thr0loc.c:

Go to the source code of this file.
Classes | |
| struct | thr_local_struct |
Defines | |
| #define | THR_LOCAL_MAGIC_N 1231234 |
Typedefs | |
| typedef thr_local_struct | thr_local_t |
Functions | |
| static thr_local_t * | thr_local_get (os_thread_id_t id) |
| ulint | thr_local_get_slot_no (os_thread_id_t id) |
| void | thr_local_set_slot_no (os_thread_id_t id, ulint slot_no) |
| ibool * | thr_local_get_in_ibuf_field (void) |
| void | thr_local_create (void) |
| void | thr_local_free (os_thread_id_t id) |
| void | thr_local_init (void) |
Variables | |
| mutex_t | thr_local_mutex |
| hash_table_t * | thr_local_hash = NULL |
| #define THR_LOCAL_MAGIC_N 1231234 |
Definition at line 52 of file thr0loc.c.
Referenced by thr_local_create(), thr_local_free(), and thr_local_get().
| typedef struct thr_local_struct thr_local_t |
| void thr_local_create | ( | void | ) |
Definition at line 159 of file thr0loc.c.
References FALSE, hash(), HASH_INSERT, local, mem_alloc, mutex_enter, mutex_exit(), NULL, os_thread_get_curr(), os_thread_get_curr_id(), os_thread_pf(), thr_local_hash, thr_local_init(), THR_LOCAL_MAGIC_N, and thr_local_mutex.
Referenced by srv_table_reserve_slot(), and thr_local_get().
00161 { 00162 thr_local_t* local; 00163 00164 if (thr_local_hash == NULL) { 00165 thr_local_init(); 00166 } 00167 00168 local = mem_alloc(sizeof(thr_local_t)); 00169 00170 local->id = os_thread_get_curr_id(); 00171 local->handle = os_thread_get_curr(); 00172 local->magic_n = THR_LOCAL_MAGIC_N; 00173 00174 local->in_ibuf = FALSE; 00175 00176 mutex_enter(&thr_local_mutex); 00177 00178 HASH_INSERT(thr_local_t, hash, thr_local_hash, 00179 os_thread_pf(os_thread_get_curr_id()), 00180 local); 00181 00182 mutex_exit(&thr_local_mutex); 00183 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void thr_local_free | ( | os_thread_id_t | id | ) |
Definition at line 189 of file thr0loc.c.
References hash(), HASH_DELETE, HASH_SEARCH, local, mem_free, mutex_enter, mutex_exit(), NULL, os_thread_eq(), os_thread_pf(), thr_local_hash, THR_LOCAL_MAGIC_N, thr_local_mutex, and ut_a.
00191 : thread id */ 00192 { 00193 thr_local_t* local; 00194 00195 mutex_enter(&thr_local_mutex); 00196 00197 /* Look for the local struct in the hash table */ 00198 00199 HASH_SEARCH(hash, thr_local_hash, os_thread_pf(id), 00200 local, os_thread_eq(local->id, id)); 00201 if (local == NULL) { 00202 mutex_exit(&thr_local_mutex); 00203 00204 return; 00205 } 00206 00207 HASH_DELETE(thr_local_t, hash, thr_local_hash, 00208 os_thread_pf(id), local); 00209 00210 mutex_exit(&thr_local_mutex); 00211 00212 ut_a(local->magic_n == THR_LOCAL_MAGIC_N); 00213 00214 mem_free(local); 00215 }
Here is the call graph for this function:

| static thr_local_t* thr_local_get | ( | os_thread_id_t | id | ) | [static] |
Definition at line 58 of file thr0loc.c.
References hash(), HASH_SEARCH, local, mutex_enter, mutex_exit(), NULL, os_thread_eq(), os_thread_pf(), thr_local_create(), thr_local_hash, THR_LOCAL_MAGIC_N, thr_local_mutex, and ut_ad.
Referenced by thr_local_get_in_ibuf_field(), thr_local_get_slot_no(), and thr_local_set_slot_no().
00060 : local storage */ 00061 os_thread_id_t id) /* in: thread id of the thread */ 00062 { 00063 thr_local_t* local; 00064 00065 try_again: 00066 ut_ad(thr_local_hash); 00067 #ifdef UNIV_SYNC_DEBUG 00068 ut_ad(mutex_own(&thr_local_mutex)); 00069 #endif /* UNIV_SYNC_DEBUG */ 00070 00071 /* Look for the local struct in the hash table */ 00072 00073 local = NULL; 00074 00075 HASH_SEARCH(hash, thr_local_hash, os_thread_pf(id), 00076 local, os_thread_eq(local->id, id)); 00077 if (local == NULL) { 00078 mutex_exit(&thr_local_mutex); 00079 00080 thr_local_create(); 00081 00082 mutex_enter(&thr_local_mutex); 00083 00084 goto try_again; 00085 } 00086 00087 ut_ad(local->magic_n == THR_LOCAL_MAGIC_N); 00088 00089 return(local); 00090 }
Here is the call graph for this function:

Here is the caller graph for this function:

| ibool* thr_local_get_in_ibuf_field | ( | void | ) |
Definition at line 140 of file thr0loc.c.
References local, mutex_enter, mutex_exit(), os_thread_get_curr_id(), thr_local_get(), and thr_local_mutex.
Referenced by ibuf_enter(), ibuf_exit(), and ibuf_inside().
00142 : pointer to the in_ibuf field */ 00143 { 00144 thr_local_t* local; 00145 00146 mutex_enter(&thr_local_mutex); 00147 00148 local = thr_local_get(os_thread_get_curr_id()); 00149 00150 mutex_exit(&thr_local_mutex); 00151 00152 return(&(local->in_ibuf)); 00153 }
Here is the call graph for this function:

Here is the caller graph for this function:

| ulint thr_local_get_slot_no | ( | os_thread_id_t | id | ) |
Definition at line 96 of file thr0loc.c.
References local, mutex_enter, mutex_exit(), thr_local_get(), and thr_local_mutex.
Referenced by srv_get_thread_type(), and srv_suspend_thread().
00098 : slot number */ 00099 os_thread_id_t id) /* in: thread id of the thread */ 00100 { 00101 ulint slot_no; 00102 thr_local_t* local; 00103 00104 mutex_enter(&thr_local_mutex); 00105 00106 local = thr_local_get(id); 00107 00108 slot_no = local->slot_no; 00109 00110 mutex_exit(&thr_local_mutex); 00111 00112 return(slot_no); 00113 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void thr_local_init | ( | void | ) |
Definition at line 221 of file thr0loc.c.
References hash_create(), mutex_create, NULL, OS_THREAD_MAX_N, SYNC_THR_LOCAL, thr_local_hash, thr_local_mutex, and ut_a.
Referenced by srv_general_init(), and thr_local_create().
00223 { 00224 00225 ut_a(thr_local_hash == NULL); 00226 00227 thr_local_hash = hash_create(OS_THREAD_MAX_N + 100); 00228 00229 mutex_create(&thr_local_mutex, SYNC_THR_LOCAL); 00230 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void thr_local_set_slot_no | ( | os_thread_id_t | id, | |
| ulint | slot_no | |||
| ) |
Definition at line 119 of file thr0loc.c.
References local, mutex_enter, mutex_exit(), thr_local_get(), and thr_local_mutex.
Referenced by srv_table_reserve_slot().
00121 : thread id of the thread */ 00122 ulint slot_no)/* in: slot number */ 00123 { 00124 thr_local_t* local; 00125 00126 mutex_enter(&thr_local_mutex); 00127 00128 local = thr_local_get(id); 00129 00130 local->slot_no = slot_no; 00131 00132 mutex_exit(&thr_local_mutex); 00133 }
Here is the call graph for this function:

Here is the caller graph for this function:

| hash_table_t* thr_local_hash = NULL |
Definition at line 34 of file thr0loc.c.
Referenced by thr_local_create(), thr_local_free(), thr_local_get(), and thr_local_init().
Definition at line 31 of file thr0loc.c.
Referenced by thr_local_create(), thr_local_free(), thr_local_get(), thr_local_get_in_ibuf_field(), thr_local_get_slot_no(), thr_local_init(), and thr_local_set_slot_no().
1.4.7

