diff options
author | nw1 <nw1@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1997-08-28 08:33:01 +0000 |
---|---|---|
committer | nw1 <nw1@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1997-08-28 08:33:01 +0000 |
commit | f25772e0cda8ac7268aa63ed2bdc5590b20fd39a (patch) | |
tree | a5955726d74b73b1993849f7120310e4356dc957 /tests/Task_Test.cpp | |
parent | 61d8f73337d0cbb75bbffadd987bd15353779428 (diff) | |
download | ATCD-f25772e0cda8ac7268aa63ed2bdc5590b20fd39a.tar.gz |
*** empty log message ***
Diffstat (limited to 'tests/Task_Test.cpp')
-rw-r--r-- | tests/Task_Test.cpp | 38 |
1 files changed, 32 insertions, 6 deletions
diff --git a/tests/Task_Test.cpp b/tests/Task_Test.cpp index 19cf2b40038..65aeb0b14d6 100644 --- a/tests/Task_Test.cpp +++ b/tests/Task_Test.cpp @@ -30,7 +30,8 @@ class Barrier_Task : public ACE_Task<ACE_MT_SYNCH> public: Barrier_Task (ACE_Thread_Manager *thr_mgr, int n_threads, - int n_iterations); + int n_iterations, + ACE_hthread_t thread_handles[]); virtual int svc (void); // Iterate <n_iterations> time printing off a message and "waiting" @@ -47,13 +48,20 @@ private: Barrier_Task::Barrier_Task (ACE_Thread_Manager *thr_mgr, int n_threads, - int n_iterations) + int n_iterations, + ACE_hthread_t thread_handles[]) : ACE_Task<ACE_MT_SYNCH> (thr_mgr), barrier_ (n_threads), n_iterations_ (n_iterations) { // Create worker threads. - if (this->activate (THR_NEW_LWP, n_threads) == -1) + if (this->activate (THR_NEW_LWP, + n_threads, + 0, + ACE_DEFAULT_THREAD_PRIORITY, + -1, + 0, + thread_handles) == -1) ACE_ERROR ((LM_ERROR, "%p\n", "activate failed")); } @@ -93,13 +101,31 @@ main (int, char *[]) #if defined (ACE_HAS_THREADS) int n_threads = ACE_MAX_THREADS; int n_iterations = ACE_MAX_ITERATIONS; + ACE_hthread_t *thread_handles; + + ACE_NEW_RETURN (thread_handles, ACE_hthread_t[n_threads], -1); Barrier_Task barrier_task (ACE_Thread_Manager::instance (), n_threads, - n_iterations); + n_iterations, + thread_handles); + +#if !defined (VXWORKS) + // VxWorks doesn't support thr_join() semantics... Someday + // we'll fix this. + ACE_Thread_Manager::instance ()->wait (); +#else + // Wait for all the threads to reach their exit point and then join + // with all the exiting threads. + for (int i = 0; + i < n_threads; + i++) + if (ACE_Thread::join (thread_handles[i]) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "join"), -1); +#endif /* VXWORKS */ + + delete [] thread_handles; - // Wait for all the threads to reach their exit point. - ACE_Thread_Manager::instance ()->wait (); #else ACE_ERROR ((LM_ERROR, "threads not supported on this platform\n")); #endif /* ACE_HAS_THREADS */ |