diff options
author | nanbor <nanbor@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-03-09 05:35:30 +0000 |
---|---|---|
committer | nanbor <nanbor@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-03-09 05:35:30 +0000 |
commit | 724ca36c649afa08783aef75a9280e8bc8d9c0d5 (patch) | |
tree | d7a8ed5935e7fc39732bcbf7a83dadff0bda27cb | |
parent | 2c397537b72841e63d3a24f0eb6b04dbfc281a7e (diff) | |
download | ATCD-724ca36c649afa08783aef75a9280e8bc8d9c0d5.tar.gz |
Added functions to collect group thr ids/handles and check if a thread is managed by TM.
-rw-r--r-- | ace/Thread_Manager.cpp | 89 | ||||
-rw-r--r-- | ace/Thread_Manager.h | 25 |
2 files changed, 109 insertions, 5 deletions
diff --git a/ace/Thread_Manager.cpp b/ace/Thread_Manager.cpp index 9121aa948b8..71b0c7c1c26 100644 --- a/ace/Thread_Manager.cpp +++ b/ace/Thread_Manager.cpp @@ -1258,6 +1258,38 @@ ACE_Thread_Manager::testcancel (ACE_thread_t t_id) return this->check_state (ACE_THR_CANCELLED, t_id); } +// Thread information query functions. + +int +ACE_Thread_Manager::hthread_within (ACE_hthread_t handle) +{ + ACE_TRACE ("ACE_Thread_Manager::hthread_within"); + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_monx, this->lock_, -1)); + + for (ACE_Double_Linked_List_Iterator<ACE_Thread_Descriptor> iter (this->thr_list_); + !iter.done (); + iter.advance ()) + if (iter.next ()->thr_handle_ == handle) + return 1; + + return 0; +} + +int +ACE_Thread_Manager::thread_within (ACE_thread_t tid) +{ + ACE_TRACE ("ACE_Thread_Manager::thread_within"); + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_monx, this->lock_, -1)); + + for (ACE_Double_Linked_List_Iterator<ACE_Thread_Descriptor> iter (this->thr_list_); + !iter.done (); + iter.advance ()) + if (iter.next ()->thr_id_ == tid) + return 1; + + return 0; +} + // Get group ids for a particular thread id. int @@ -2095,7 +2127,7 @@ ACE_Thread_Manager::hthread_list (ACE_Task_Base *task, ACE_hthread_t hthread_list[], size_t n) { - ACE_TRACE ("ACE_Thread_Manager::thread_list"); + ACE_TRACE ("ACE_Thread_Manager::hthread_list"); ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1)); size_t hthread_count = 0; @@ -2118,6 +2150,61 @@ ACE_Thread_Manager::hthread_list (ACE_Task_Base *task, } int +ACE_Thread_Manager::thread_grp_list (int grp_id, + ACE_thread_t thread_list[], + size_t n) +{ + ACE_TRACE ("ACE_Thread_Manager::thread_grp_list"); + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1)); + + size_t thread_count = 0; + + for (ACE_Double_Linked_List_Iterator<ACE_Thread_Descriptor> iter (this->thr_list_); + !iter.done (); + iter.advance ()) + { + if (thread_count >= n) + break; + + if (iter.next ()->grp_id_ == grp_id) + { + thread_list[thread_count] = iter.next ()->thr_id_; + thread_count ++; + } + } + return 0; +} + +// Returns in thread_list a list of thread handles in an ACE_Task. + +int +ACE_Thread_Manager::hthread_grp_list (int grp_id, + ACE_hthread_t hthread_list[], + size_t n) +{ + ACE_TRACE ("ACE_Thread_Manager::hthread_list"); + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1)); + + size_t hthread_count = 0; + + for (ACE_Double_Linked_List_Iterator<ACE_Thread_Descriptor> iter (this->thr_list_); + !iter.done (); + iter.advance ()) + { + if (hthread_count >= n) + break; + + if (iter.next ()->grp_id_ == grp_id) + { + hthread_list[hthread_count] = iter.next ()->thr_handle_; + hthread_count ++; + } + } + + return 0; +} + +int ACE_Thread_Manager::set_grp (ACE_Task_Base *task, int grp_id) { ACE_TRACE ("ACE_Thread_Manager::set_grp"); diff --git a/ace/Thread_Manager.h b/ace/Thread_Manager.h index a90215c2587..74e5025ea3d 100644 --- a/ace/Thread_Manager.h +++ b/ace/Thread_Manager.h @@ -618,9 +618,12 @@ public: // supports cancellation. Otherwise, perform a "cooperative" // cancellation. - // = The following method provide new functionality. They do not - // follow the same design as current methods. They provide new - // functionality. + // = Collect thread handles in the thread manager. Notice that + // the collected information is just a snapshot. + int hthread_within (ACE_hthread_t handle); + int thread_within (ACE_thread_t tid); + // Check if the thread is managed by the thread manager. Return true if + // the thread is found, false otherwise. int num_tasks_in_group (int grp_id); // Returns the number of <ACE_Task_Base> in a group. @@ -637,7 +640,7 @@ public: int thread_list (ACE_Task_Base *task, ACE_thread_t thread_list[], size_t n); - // Returns in <thread_list> a list of up to <h> thread ids in an + // Returns in <thread_list> a list of up to <n> thread ids in an // <ACE_Task_Base>. The caller must allocate the memory for // <thread_list>. @@ -648,6 +651,20 @@ public: // an <ACE_Task_Base>. The caller must allocate memory for // <hthread_list>. + int thread_grp_list (int grp_id, + ACE_thread_t thread_list[], + size_t n); + // Returns in <thread_list> a list of up to <n> thread ids in a + // group <grp_id>. The caller must allocate the memory for + // <thread_list>. + + int hthread_grp_list (int grp_id, + ACE_hthread_t hthread_list[], + size_t n); + // Returns in <hthread_list> a list of up to <n> thread handles in + // a group <grp_id>. The caller must allocate memory for + // <hthread_list>. + // = Set/get group ids for a particular task. int set_grp (ACE_Task_Base *task, int grp_id); int get_grp (ACE_Task_Base *task, int &grp_id); |