2 #include "ace/OS_NS_string.h"
4 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
6 /// Allocates a @a keyp that is used to identify data that is specific
7 /// to each thread in the process. The key is global to all threads in
10 ACE_Thread::keycreate (ACE_thread_key_t *keyp,
11 #if defined (ACE_HAS_THR_C_DEST)
12 ACE_THR_C_DEST destructor
14 ACE_THR_DEST destructor
15 #endif /* ACE_HAS_THR_C_DEST */
18 // ACE_TRACE ("ACE_Thread::keycreate");
19 return ACE_OS::thr_keycreate (keyp, destructor);
22 /// Free up the key so that other threads can reuse it.
24 ACE_Thread::keyfree (ACE_thread_key_t key)
26 ACE_TRACE ("ACE_Thread::keyfree");
27 return ACE_OS::thr_keyfree (key);
30 /// Bind value to the thread-specific data key, @a key, for the calling
33 ACE_Thread::setspecific (ACE_thread_key_t key, void *value)
35 // ACE_TRACE ("ACE_Thread::setspecific");
36 return ACE_OS::thr_setspecific (key, value);
39 /// Stores the current value bound to @a key> for the calling thread
40 /// into the location pointed to by @a valuep.
42 ACE_Thread::getspecific (ACE_thread_key_t key, void **valuep)
44 // ACE_TRACE ("ACE_Thread::getspecific");
45 return ACE_OS::thr_getspecific (key, valuep);
48 ACE_INLINE ACE_thread_t
51 // ACE_TRACE ("ACE_Thread::self");
52 return ACE_OS::thr_self ();
56 ACE_Thread::exit (ACE_THR_FUNC_RETURN status)
58 ACE_TRACE ("ACE_Thread::exit");
59 ACE_OS::thr_exit (status);
65 ACE_TRACE ("ACE_Thread::yield");
70 ACE_Thread::spawn (ACE_THR_FUNC func,
74 ACE_hthread_t *t_handle,
77 size_t thr_stack_size,
78 ACE_Thread_Adapter *thread_adapter,
79 const char** thr_name)
81 ACE_TRACE ("ACE_Thread::spawn");
83 return ACE_OS::thr_create (func,
96 ACE_Thread::resume (ACE_hthread_t t_id)
98 ACE_TRACE ("ACE_Thread::resume");
99 return ACE_OS::thr_continue (t_id);
103 ACE_Thread::suspend (ACE_hthread_t t_id)
105 ACE_TRACE ("ACE_Thread::suspend");
106 return ACE_OS::thr_suspend (t_id);
110 ACE_Thread::kill (ACE_thread_t t_id, int signum)
112 ACE_TRACE ("ACE_Thread::kill");
113 return ACE_OS::thr_kill (t_id, signum);
117 ACE_Thread::join (ACE_thread_t wait_for,
118 ACE_thread_t *departed,
119 ACE_THR_FUNC_RETURN *status)
121 ACE_TRACE ("ACE_Thread::join");
122 return ACE_OS::thr_join (wait_for, departed, status);
126 ACE_Thread::join (ACE_hthread_t wait_for,
127 ACE_THR_FUNC_RETURN *status)
129 ACE_TRACE ("ACE_Thread::join");
130 return ACE_OS::thr_join (wait_for, status);
134 ACE_Thread::getconcurrency ()
136 ACE_TRACE ("ACE_Thread::getconcurrency");
137 return ACE_OS::thr_getconcurrency ();
141 ACE_Thread::setconcurrency (int new_level)
143 ACE_TRACE ("ACE_Thread::setconcurrency");
144 return ACE_OS::thr_setconcurrency (new_level);
148 ACE_Thread::sigsetmask (int how,
149 const sigset_t *sigset,
152 ACE_TRACE ("ACE_Thread::sigsetmask");
153 return ACE_OS::thr_sigsetmask (how, sigset, osigset);
157 ACE_Thread::disablecancel (struct cancel_state *old_state)
159 ACE_TRACE ("ACE_Thread::disablecancel");
161 int result = ACE_OS::thr_setcancelstate (THR_CANCEL_DISABLE,
163 if (result == 0 && old_state != 0)
165 ACE_OS::memset (old_state,
167 sizeof (*old_state));
168 old_state->cancelstate = old_cstate;
175 ACE_Thread::enablecancel (struct cancel_state *old_state,
178 ACE_TRACE ("ACE_Thread::enablecancel");
183 result = ACE_OS::thr_setcancelstate (THR_CANCEL_ENABLE,
188 result = ACE_OS::thr_setcanceltype (flag,
195 old_state->cancelstate = old_cstate;
196 old_state->canceltype = old_ctype;
203 ACE_Thread::setcancelstate (struct cancel_state &new_state,
204 struct cancel_state *old_state)
206 ACE_TRACE ("ACE_Thread::setcancelstate");
210 if (new_state.cancelstate != 0
211 && ACE_OS::thr_setcancelstate (new_state.cancelstate,
215 if (new_state.canceltype != 0
216 && ACE_OS::thr_setcanceltype (new_state.canceltype,
221 ACE_OS::thr_setcancelstate (old_cstate,
228 old_state->cancelstate = old_cstate;
229 old_state->canceltype = old_ctype;
236 ACE_Thread::cancel (ACE_thread_t t_id)
238 ACE_TRACE ("ACE_Thread::cancel");
240 return ACE_OS::thr_cancel (t_id);
244 ACE_Thread::testcancel ()
246 ACE_TRACE ("ACE_Thread::testcancel");
248 ACE_OS::thr_testcancel ();
252 ACE_Thread::self (ACE_hthread_t &t_id)
254 // ACE_TRACE ("ACE_Thread::self");
255 ACE_OS::thr_self (t_id);
259 ACE_Thread::getprio (ACE_hthread_t ht_id, int &priority)
261 ACE_TRACE ("ACE_Thread::getprio");
262 return ACE_OS::thr_getprio (ht_id, priority);
266 ACE_Thread::getprio (ACE_hthread_t ht_id, int &priority, int &policy)
268 ACE_TRACE ("ACE_Thread::getprio");
269 return ACE_OS::thr_getprio (ht_id, priority, policy);
273 ACE_Thread::setprio (ACE_hthread_t ht_id, int priority, int policy)
275 ACE_TRACE ("ACE_Thread::setprio");
276 return ACE_OS::thr_setprio (ht_id, priority, policy);
279 ACE_END_VERSIONED_NAMESPACE_DECL