1
by brian
clean slate |
1 |
/* Copyright (C) 2000 MySQL AB
|
2 |
||
3 |
This program is free software; you can redistribute it and/or modify
|
|
4 |
it under the terms of the GNU General Public License as published by
|
|
5 |
the Free Software Foundation; version 2 of the License.
|
|
6 |
||
7 |
This program is distributed in the hope that it will be useful,
|
|
8 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
9 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
10 |
GNU General Public License for more details.
|
|
11 |
||
12 |
You should have received a copy of the GNU General Public License
|
|
13 |
along with this program; if not, write to the Free Software
|
|
1802.10.2
by Monty Taylor
Update all of the copyright headers to include the correct address. |
14 |
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
|
1
by brian
clean slate |
15 |
|
16 |
/*
|
|
17 |
Functions to handle initializating and allocationg of all mysys & debug
|
|
18 |
thread variables.
|
|
19 |
*/
|
|
20 |
||
2173.2.1
by Monty Taylor
Fixes incorrect usage of include |
21 |
#include <config.h> |
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
22 |
|
2173.2.1
by Monty Taylor
Fixes incorrect usage of include |
23 |
#include <drizzled/internal/my_sys.h> |
24 |
#include <drizzled/internal/thread_var.h> |
|
25 |
#include <drizzled/internal/m_string.h> |
|
612.2.6
by Monty Taylor
OpenSolaris builds. |
26 |
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
27 |
#include <cstdio> |
1
by brian
clean slate |
28 |
#include <signal.h> |
29 |
||
481.1.15
by Monty Taylor
Removed time.h and sys/time.h from global.h. |
30 |
#if TIME_WITH_SYS_TIME
|
31 |
# include <sys/time.h>
|
|
32 |
# include <time.h>
|
|
33 |
#else
|
|
34 |
# if HAVE_SYS_TIME_H
|
|
35 |
# include <sys/time.h>
|
|
36 |
# else
|
|
37 |
# include <time.h>
|
|
38 |
# endif
|
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
39 |
#endif
|
481.1.15
by Monty Taylor
Removed time.h and sys/time.h from global.h. |
40 |
|
1782
by Brian Aker
This modifies our thread system to be based on boost, and it fixes a |
41 |
#include <boost/thread/thread.hpp> |
42 |
#include <boost/thread/mutex.hpp> |
|
43 |
#include <boost/thread/tss.hpp> |
|
44 |
||
2280.1.5
by Olaf van der Spek
Refactor |
45 |
namespace drizzled { |
46 |
namespace internal { |
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
47 |
|
2415.1.4
by Brian Aker
Wrap thread specfic |
48 |
thread_local_st THR_KEY_mysys; |
1778
by Brian Aker
Cleanup of thr_init. |
49 |
boost::mutex THR_LOCK_threads; |
1
by brian
clean slate |
50 |
|
1241.9.57
by Monty Taylor
Oy. Bigger change than I normally like - but this stuff is all intertwined. |
51 |
static uint64_t thread_id= 0; |
1
by brian
clean slate |
52 |
|
53 |
/*
|
|
51.3.28
by Jay Pipes
DBUG entirely removed from server and client |
54 |
Allocate thread specific memory for the thread, used by mysys
|
1
by brian
clean slate |
55 |
|
56 |
SYNOPSIS
|
|
57 |
my_thread_init()
|
|
58 |
||
59 |
RETURN
|
|
60 |
0 ok
|
|
61 |
1 Fatal error; mysys/dbug functions can't be used
|
|
62 |
*/
|
|
63 |
||
2281.4.5
by Olaf van der Spek
Prune & refactor |
64 |
void my_thread_init() |
1
by brian
clean slate |
65 |
{
|
2385.3.8
by Olaf van der Spek
Refactor |
66 |
// We should never see my_thread_init() called twice
|
1782
by Brian Aker
This modifies our thread system to be based on boost, and it fixes a |
67 |
if (THR_KEY_mysys.get()) |
2289
by Brian Aker
Prune + abort() if programmer mistake. |
68 |
{
|
69 |
abort(); |
|
70 |
}
|
|
1778
by Brian Aker
Cleanup of thr_init. |
71 |
boost::mutex::scoped_lock scopedLock(THR_LOCK_threads); |
2280.1.6
by Olaf van der Spek
Refactor |
72 |
THR_KEY_mysys.reset(new st_my_thread_var(++thread_id)); |
1
by brian
clean slate |
73 |
}
|
74 |
||
2415.1.4
by Brian Aker
Wrap thread specfic |
75 |
thread_local_st& my_thread_var2() |
1
by brian
clean slate |
76 |
{
|
2415.1.4
by Brian Aker
Wrap thread specfic |
77 |
return THR_KEY_mysys; |
1
by brian
clean slate |
78 |
}
|
79 |
||
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
80 |
} /* namespace internal */ |
81 |
} /* namespace drizzled */ |