-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy paththread_local.inl
36 lines (30 loc) · 1005 Bytes
/
thread_local.inl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/* THOR - THOR Template Library
* Joshua M. Kriegshauser
*
* thread_local.inl
*
* Platform independent thread-local variable support implementation
*/
namespace thor
{
template<typename T> thread_local<T>::thread_local() THOR_NOTHROW
: internal::thread_local_base()
{
THOR_COMPILETIME_ASSERT(sizeof(T) <= sizeof(internal::thread_local_base::base_value_type), InvalidAssumption);
}
template<typename T> thread_local<T>::~thread_local() THOR_NOTHROW
{
}
template<typename T> typename thread_local<T>::value_type thread_local<T>::get() const THOR_NOTHROW
{
internal::thread_local_base::base_value_type v = internal::thread_local_base::get();
return *reinterpret_cast<pointer>(&v);
}
template<typename T> typename thread_local<T>::value_type thread_local<T>::set(value_type t) THOR_NOTHROW
{
internal::thread_local_base::base_value_type v =
*reinterpret_cast<internal::thread_local_base::base_value_type*>(&t);
internal::thread_local_base::set(v);
return t;
}
}