Merge pull request #2301 from sonndinh/remove-dup-reactor-functions
[ACE_TAO.git] / TAO / tests / Bug_1495_Regression / tid_to_int.h
blob33fff902b16a7a1f4797fedb1cbfb43b673c3a53
1 // -*- C++ -*-
3 /**
4 * @file tid_to_int.h
6 * Convert an ACE_thread_t to an integer in a way that doesn't rely
7 * heavily on platform-specific configuration.
9 * @author Ossama Othman
12 namespace
14 template<typename thread_id_type, typename ace_thread_id_type>
15 struct ACE_thread_t_to_integer_i
17 thread_id_type operator() (ace_thread_id_type tid)
19 // We assume sizeof(thread_id_type) >= sizeof(ace_thread_id_type).
20 return (thread_id_type) (tid);
24 template<typename thread_id_type, typename ace_thread_id_type>
25 struct ACE_thread_t_to_integer_i<thread_id_type, ace_thread_id_type*>
27 thread_id_type operator() (ace_thread_id_type* tid)
29 // ACE_thread_t is a pointer. Cast to an intermediate integer
30 // type large enough to hold a pointer.
31 intptr_t const tmp = reinterpret_cast<intptr_t> (tid);
33 // We assume sizeof(thread_id_type) >= sizeof(ace_thread_id_type).
34 return (thread_id_type) tmp;
38 template<typename thread_id_type>
39 thread_id_type
40 ACE_thread_t_to_integer (ACE_thread_t tid)
42 return ACE_thread_t_to_integer_i<thread_id_type, ACE_thread_t>() (tid);