00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <config.h>
00022
00023 #include <drizzled/internal/my_sys.h>
00024 #include <drizzled/internal/thread_var.h>
00025 #include <drizzled/internal/m_string.h>
00026
00027 #include <cstdio>
00028 #include <signal.h>
00029
00030 #if TIME_WITH_SYS_TIME
00031 # include <sys/time.h>
00032 # include <time.h>
00033 #else
00034 # if HAVE_SYS_TIME_H
00035 # include <sys/time.h>
00036 # else
00037 # include <time.h>
00038 # endif
00039 #endif
00040
00041 #include <boost/thread/thread.hpp>
00042 #include <boost/thread/mutex.hpp>
00043 #include <boost/thread/tss.hpp>
00044
00045 namespace drizzled {
00046 namespace internal {
00047
00048 thread_local_st THR_KEY_mysys;
00049 boost::mutex THR_LOCK_threads;
00050
00051 static uint64_t thread_id= 0;
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064 void my_thread_init()
00065 {
00066
00067 if (THR_KEY_mysys.get())
00068 {
00069 abort();
00070 }
00071 boost::mutex::scoped_lock scopedLock(THR_LOCK_threads);
00072 THR_KEY_mysys.reset(new st_my_thread_var(++thread_id));
00073 }
00074
00075 thread_local_st& my_thread_var2()
00076 {
00077 return THR_KEY_mysys;
00078 }
00079
00080 }
00081 }