diff options
author | schmidt <douglascraigschmidt@users.noreply.github.com> | 1999-06-15 19:58:59 +0000 |
---|---|---|
committer | schmidt <douglascraigschmidt@users.noreply.github.com> | 1999-06-15 19:58:59 +0000 |
commit | 5c86c7fd1495ef2b1bace695a09454c1ee0198e9 (patch) | |
tree | c8e3ea482211118b19e59ac4eee49f6850da1969 /tests | |
parent | 61ec7b073dd75ca38dc0a87ebfcdac7aefa84c20 (diff) | |
download | ATCD-5c86c7fd1495ef2b1bace695a09454c1ee0198e9.tar.gz |
.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Thread_Manager_Test.cpp | 53 |
1 files changed, 34 insertions, 19 deletions
diff --git a/tests/Thread_Manager_Test.cpp b/tests/Thread_Manager_Test.cpp index d947bb7de65..ee81041d1b5 100644 --- a/tests/Thread_Manager_Test.cpp +++ b/tests/Thread_Manager_Test.cpp @@ -41,12 +41,12 @@ static u_int n_threads = ACE_MAX_THREADS; // Helper function that looks for an existing entry in the signalled // array. Also finds the position of the first unused entry in the // array, and updates if requested with the t_id. -extern "C" -int +extern "C" int been_signalled (const ACE_thread_t t_id, const u_int update = 0) { u_int unused_slot = n_threads; + for (u_int i = 0; i < n_threads; ++i) { if (ACE_OS::thr_equal (signalled[i], t_id)) @@ -72,8 +72,7 @@ been_signalled (const ACE_thread_t t_id, // dynamically allocated, before spawning any threads. static ACE_Barrier *thread_start = 0; -extern "C" -void +extern "C" void handler (int /* signum */) { if (signalled) @@ -92,7 +91,8 @@ worker (int iterations) { #if defined (VXWORKS) ACE_DEBUG ((LM_DEBUG, ASYS_TEXT ("(%P|%t) %s: stack size is %u\n"), - ACE_OS::thr_self (), ACE_OS::thr_min_stack ())); + ACE_OS::thr_self (), + ACE_OS::thr_min_stack ())); #endif /* VXWORKS */ #if !defined (ACE_LACKS_UNIX_SIGNALS) @@ -177,18 +177,26 @@ main (int, ASYS_TCHAR *[]) #if defined (VXWORKS) // Assign thread (VxWorks task) names to test that feature. ACE_thread_t *thread_name; - ACE_NEW_RETURN (thread_name, ACE_thread_t[n_threads], -1); + ACE_NEW_RETURN (thread_name, + ACE_thread_t[n_threads], + -1); // And test the ability to specify stack size. size_t *stack_size; - ACE_NEW_RETURN (stack_size, size_t[n_threads], -1); + ACE_NEW_RETURN (stack_size, + size_t[n_threads], + -1); for (i = 0; i < n_threads; ++i) { if (i < n_threads - 1) { - ACE_NEW_RETURN (thread_name[i], char[32], -1); - ACE_OS::sprintf (thread_name[i], ASYS_TEXT ("thread%u"), i); + ACE_NEW_RETURN (thread_name[i], + char[32], + -1); + ACE_OS::sprintf (thread_name[i], + ASYS_TEXT ("thread%u"), + i); } else // Pass an ACE_thread_t pointer of 0 for the last thread name. @@ -252,24 +260,31 @@ main (int, ASYS_TCHAR *[]) ASYS_TEXT ("(%t) signaling group\n"))); #if defined (ACE_HAS_WTHREADS) - thr_mgr->kill_grp (grp_id, SIGINT); + thr_mgr->kill_grp (grp_id, + SIGINT); +#elif defined (sun) + // There seem to be bugs with Solaris that cause problems when + // thr_self() is called within a signal handler. #elif !defined (ACE_HAS_PTHREADS_DRAFT4) - ACE_ASSERT (thr_mgr->kill_grp (grp_id, SIGINT) != -1); + ACE_ASSERT (thr_mgr->kill_grp (grp_id, + SIGINT) != -1); #else - if (thr_mgr->kill_grp (grp_id, SIGINT) == -1) + if (thr_mgr->kill_grp (grp_id, + SIGINT) == -1) ACE_ASSERT (errno == ENOTSUP); #endif /* ACE_HAS_WTHREADS */ // Wait and then cancel all the threads. ACE_OS::sleep (ACE_Time_Value (1)); - ACE_DEBUG ((LM_DEBUG, ASYS_TEXT ("(%t) cancelling group\n"))); + ACE_DEBUG ((LM_DEBUG, + ASYS_TEXT ("(%t) cancelling group\n"))); ACE_ASSERT (thr_mgr->cancel_grp (grp_id) != -1); // Perform a barrier wait until all the threads have shut down. - // But, wait for a limited time because sometimes the test hangs - // on SunOS 5.5.1 and 5.7. + // But, wait for a limited time because sometimes the test hangs on + // SunOS 5.5.1 and 5.7. const ACE_Time_Value max_wait (60); const ACE_Time_Value wait_time (ACE_OS::gettimeofday () + max_wait); if (thr_mgr->wait (&wait_time) == -1) @@ -279,8 +294,8 @@ main (int, ASYS_TCHAR *[]) ASYS_TEXT ("maximum wait time of %d msec exceeded\n"), max_wait.msec ())); else - ACE_OS::perror ("wait"); - + ACE_ERROR ((LM_ERROR, + "%p\n", "wait")); status = -1; } @@ -297,8 +312,8 @@ main (int, ASYS_TCHAR *[]) for (i = 0; i < n_threads - 1; ++i) { delete [] thread_name[i]; - // Don't delete the last thread_name, because it points - // to the name in the TCB. It was initially 0. + // Don't delete the last thread_name, because it points to the + // name in the TCB. It was initially 0. } delete [] thread_name; delete [] stack_size; |