blob: aec042a2aa374f8ca703ea58b5d715ba5fc2928e (
plain)
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
37
38
39
40
41
42
43
44
45
|
// -*- C++ -*-
/**
* @file tid_to_int.h
*
* Convert an ACE_thread_t to an integer in a way that doesn't rely
* heavily on platform-specific configuration.
*
* @author Ossama Othman
*/
namespace
{
template<typename thread_id_type, typename ace_thread_id_type>
struct ACE_thread_t_to_integer_i
{
thread_id_type operator() (ace_thread_id_type tid)
{
// We assume sizeof(thread_id_type) >= sizeof(ace_thread_id_type).
return (thread_id_type) (tid);
}
};
template<typename thread_id_type, typename ace_thread_id_type>
struct ACE_thread_t_to_integer_i<thread_id_type, ace_thread_id_type*>
{
thread_id_type operator() (ace_thread_id_type* tid)
{
// ACE_thread_t is a pointer. Cast to an intermediate integer
// type large enough to hold a pointer.
intptr_t const tmp = reinterpret_cast<intptr_t> (tid);
// We assume sizeof(thread_id_type) >= sizeof(ace_thread_id_type).
return (thread_id_type) tmp;
}
};
template<typename thread_id_type>
thread_id_type
ACE_thread_t_to_integer (ACE_thread_t tid)
{
return ACE_thread_t_to_integer_i<thread_id_type, ACE_thread_t>() (tid);
}
}
|