diff options
author | schmidt <douglascraigschmidt@users.noreply.github.com> | 2013-05-07 15:12:26 +0000 |
---|---|---|
committer | schmidt <douglascraigschmidt@users.noreply.github.com> | 2013-05-07 15:12:26 +0000 |
commit | 3c643e63efa9697d97fd1273de91945d0cb62c58 (patch) | |
tree | a114b10ea4c43a37d159654d28c471ec46c9f887 | |
parent | 91583cc85a366cecf4351ddb50b1dbb75433967a (diff) | |
download | ATCD-3c643e63efa9697d97fd1273de91945d0cb62c58.tar.gz |
ChangeLogTag:Tue
-rw-r--r-- | ACE/ChangeLog | 6 | ||||
-rw-r--r-- | ACE/ace/OS_NS_Thread.h | 5 | ||||
-rw-r--r-- | ACE/ace/OS_NS_Thread.inl | 33 | ||||
-rw-r--r-- | ACE/tests/TP_Reactor_Test.cpp | 2 | ||||
-rw-r--r-- | ACE/tests/Thread_Manager_Test.cpp | 6 |
5 files changed, 49 insertions, 3 deletions
diff --git a/ACE/ChangeLog b/ACE/ChangeLog index e324e41832c..3414f95f05a 100644 --- a/ACE/ChangeLog +++ b/ACE/ChangeLog @@ -1,3 +1,9 @@ +Tue May 7 15:04:24 UTC 2013 Douglas C. Schmidt <schmidt@dre.vanderbilt.edu> + + * ace/OS_NS_Thread.{h,inl}: Added a new ACE_OS::thr_id() method + that stores a string version of the current thread id into + buffer and returns the size of this thread id in bytes. + Thu Apr 25 16:51:06 UTC 2013 Douglas C. Schmidt <schmidt@dre.vanderbilt.edu> * ace/Svc_Handler.h: diff --git a/ACE/ace/OS_NS_Thread.h b/ACE/ace/OS_NS_Thread.h index 2cbe9679a77..c6db5db25df 100644 --- a/ACE/ace/OS_NS_Thread.h +++ b/ACE/ace/OS_NS_Thread.h @@ -1720,6 +1720,11 @@ namespace ACE_OS { ACE_NAMESPACE_INLINE_FUNCTION const char* thr_name (void); + // Stores a string version of the current thread id into buffer and + // returns the size of this thread id in bytes. + ACE_NAMESPACE_INLINE_FUNCTION + ssize_t thr_id (char buffer[], size_t buffer_length); + /// State is THR_CANCEL_ENABLE or THR_CANCEL_DISABLE ACE_NAMESPACE_INLINE_FUNCTION int thr_setcancelstate (int new_state, int *old_state); diff --git a/ACE/ace/OS_NS_Thread.inl b/ACE/ace/OS_NS_Thread.inl index 054f9187a3d..f0bb59cb345 100644 --- a/ACE/ace/OS_NS_Thread.inl +++ b/ACE/ace/OS_NS_Thread.inl @@ -3079,6 +3079,39 @@ ACE_OS::thr_min_stack (void) #endif /* ACE_HAS_THREADS */ } +ACE_INLINE ssize_t +ACE_OS::thr_id (char buffer[], size_t buffer_length) +{ +#if defined (ACE_WIN32) +#if defined (ACE_HAS_SNPRINTF) + return_OS::snprintf (buffer, + buffer_length, + "u", + static_cast <unsigned> (ACE_Thread::self ())); +#else + ACE_UNUSED_ARG (buffer_length); + return_OS::sprintf (buffer, + "u", + static_cast <unsigned> (ACE_Thread::self ())); +} +#endif /* ACE_HAS_SNPRINTF */ +#else + ACE_hthread_t t_id; + ACE_OS::thr_self (t_id); +#if defined (ACE_HAS_SNPRINTF) + return ACE_OS::snprintf (buffer, + buffer_length, + "%lu", + (unsigned long) t_id); +#else + ACE_UNUSED_ARG (buffer_length); + return ACE_OS::sprintf (buffer, + "%lu", + (unsigned long) t_id); +#endif /* ACE_HAS_SNPRINTF */ +#endif /* WIN32 */ +} + ACE_INLINE ACE_thread_t ACE_OS::thr_self (void) { diff --git a/ACE/tests/TP_Reactor_Test.cpp b/ACE/tests/TP_Reactor_Test.cpp index 1dcb7f5612e..0bbcce24219 100644 --- a/ACE/tests/TP_Reactor_Test.cpp +++ b/ACE/tests/TP_Reactor_Test.cpp @@ -65,8 +65,6 @@ #include "ace/Synch_Traits.h" #include "ace/Thread_Semaphore.h" - - // Some debug helper functions static int disable_signal (int sigmin, int sigmax); diff --git a/ACE/tests/Thread_Manager_Test.cpp b/ACE/tests/Thread_Manager_Test.cpp index 038add75f0a..68adabbc3d8 100644 --- a/ACE/tests/Thread_Manager_Test.cpp +++ b/ACE/tests/Thread_Manager_Test.cpp @@ -128,9 +128,13 @@ worker (int iterations) #else if (thr_mgr->testcancel (ACE_Thread::self ()) != 0) { + char thr_id[BUFSIZ]; + // Test out the ACE_OS::thr_id() method. + ssize_t len = ACE_OS::thr_id (thr_id, sizeof thr_id); ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("(%t) has been cancelled ") + ACE_TEXT ("(%s) has been cancelled ") ACE_TEXT ("before iteration %d!\n"), + thr_id, i)); break; } |