2 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
5 ACE_At_Thread_Exit::ACE_At_Thread_Exit ()
14 ACE_At_Thread_Exit::was_applied() const
20 ACE_At_Thread_Exit::was_applied (bool applied)
22 was_applied_ = applied;
29 ACE_At_Thread_Exit::is_owner() const
35 ACE_At_Thread_Exit::is_owner (bool owner)
42 ACE_At_Thread_Exit::do_apply ()
44 if (!this->was_applied_ && this->is_owner_)
49 ACE_At_Thread_Exit_Func::ACE_At_Thread_Exit_Func (void *object,
50 ACE_CLEANUP_FUNC func,
59 ACE_Thread_Descriptor_Base::ACE_Thread_Descriptor_Base ()
60 : ACE_OS_Thread_Descriptor (),
61 thr_id_ (ACE_OS::NULL_thread),
62 thr_handle_ (ACE_OS::NULL_hthread),
64 thr_state_ (ACE_Thread_Manager::ACE_THR_IDLE),
72 ACE_Thread_Descriptor_Base::~ACE_Thread_Descriptor_Base ()
77 ACE_Thread_Descriptor_Base::operator== (
78 const ACE_Thread_Descriptor_Base &rhs) const
81 ACE_OS::thr_cmp (this->thr_handle_, rhs.thr_handle_)
82 && ACE_OS::thr_equal (this->thr_id_, rhs.thr_id_);
86 ACE_Thread_Descriptor_Base::operator!=(const ACE_Thread_Descriptor_Base &rhs) const
88 return !(*this == rhs);
91 ACE_INLINE ACE_Task_Base *
92 ACE_Thread_Descriptor_Base::task () const
94 ACE_TRACE ("ACE_Thread_Descriptor_Base::task");
101 ACE_Thread_Descriptor_Base::grp_id () const
103 ACE_TRACE ("ACE_Thread_Descriptor_Base::grp_id");
107 // Current state of the thread.
108 ACE_INLINE ACE_UINT32
109 ACE_Thread_Descriptor_Base::state () const
111 ACE_TRACE ("ACE_Thread_Descriptor_Base::state");
115 // Reset this base descriptor.
117 ACE_Thread_Descriptor_Base::reset ()
119 ACE_TRACE ("ACE_Thread_Descriptor_Base::reset");
120 this->thr_id_ = ACE_OS::NULL_thread;
121 this->thr_handle_ = ACE_OS::NULL_hthread;
123 this->thr_state_ = ACE_Thread_Manager::ACE_THR_IDLE;
129 ACE_INLINE ACE_thread_t
130 ACE_Thread_Descriptor::self () const
132 ACE_TRACE ("ACE_Thread_Descriptor::self");
133 return this->thr_id_;
136 // Unique kernel-level thread handle.
139 ACE_Thread_Descriptor::self (ACE_hthread_t &handle)
141 ACE_TRACE ("ACE_Thread_Descriptor::self");
142 handle = this->thr_handle_;
146 ACE_Thread_Descriptor::log_msg_cleanup (ACE_Log_Msg* log_msg)
152 // Set the <next_> pointer
154 ACE_Thread_Descriptor::set_next (ACE_Thread_Descriptor *td)
156 ACE_TRACE ("ACE_Thread_Descriptor::set_next");
160 // Get the <next_> pointer
161 ACE_INLINE ACE_Thread_Descriptor *
162 ACE_Thread_Descriptor::get_next () const
164 ACE_TRACE ("ACE_Thread_Descriptor::get_next");
165 return static_cast<ACE_Thread_Descriptor *> (this->next_);
168 // Reset this thread descriptor
170 ACE_Thread_Descriptor::reset (ACE_Thread_Manager *tm)
172 ACE_TRACE ("ACE_Thread_Descriptor::reset");
173 this->ACE_Thread_Descriptor_Base::reset ();
174 this->at_exit_list_ = 0;
175 // Start the at_exit hook list.
177 // Setup the Thread_Manager.
179 this->terminated_ = false;
182 ACE_INLINE ACE_Thread_Descriptor *
183 ACE_Thread_Manager::thread_desc_self ()
185 // This method must be called with lock held.
187 // Try to get it from cache.
188 ACE_Thread_Descriptor *desc = ACE_LOG_MSG->thr_desc ();
191 // ACE_ASSERT (desc != 0);
192 // Thread descriptor should always get cached.
196 ACE_thread_t id = ACE_OS::thr_self ();
198 desc = this->find_thread (id);
200 // Thread descriptor adapter might not have been put into the
203 // Update the TSS cache.
204 ACE_LOG_MSG->thr_desc (desc);
210 // Return the unique ID of the thread.
212 ACE_INLINE ACE_thread_t
213 ACE_Thread_Manager::thr_self ()
215 ACE_TRACE ("ACE_Thread_Manager::thr_self");
216 return ACE_Thread::self ();
219 ACE_INLINE ACE_Task_Base *
220 ACE_Thread_Manager::task ()
222 ACE_TRACE ("ACE_Thread_Manager::task");
224 ACE_Thread_Descriptor *td = this->thread_desc_self () ;
233 ACE_Thread_Manager::open (size_t)
240 ACE_Thread_Manager::at_exit (ACE_At_Thread_Exit* at)
242 ACE_Thread_Descriptor *td = this->thread_desc_self ();
246 return td->at_exit (at);
250 ACE_Thread_Manager::at_exit (ACE_At_Thread_Exit& at)
252 ACE_Thread_Descriptor *td = this->thread_desc_self ();
256 return td->at_exit (at);
260 ACE_Thread_Manager::at_exit (void *object,
261 ACE_CLEANUP_FUNC cleanup_hook,
264 ACE_Thread_Descriptor *td = this->thread_desc_self ();
268 return td->at_exit (object, cleanup_hook, param);
272 ACE_Thread_Manager::wait_on_exit (int do_wait)
274 this->automatic_wait_ = do_wait;
278 ACE_Thread_Manager::wait_on_exit ()
280 return this->automatic_wait_;
284 ACE_Thread_Manager::register_as_terminated (ACE_Thread_Descriptor *td)
286 #if defined (ACE_HAS_VXTHREADS)
288 #else /* ! ACE_HAS_VXTHREADS */
289 ACE_Thread_Descriptor_Base *tdb = 0;
290 ACE_NEW_RETURN (tdb, ACE_Thread_Descriptor_Base (*td), -1);
291 this->terminated_thr_list_.insert_tail (tdb);
292 #endif /* !ACE_HAS_VXTHREADS */
297 ACE_Thread_Manager::count_threads () const
299 return this->thr_list_.size ();
302 ACE_END_VERSIONED_NAMESPACE_DECL