00001
00002
00003
00004
00005 #include "ace/OS_NS_string.h"
00006
00007 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00008
00009
00010
00011
00012
00013 ACE_INLINE int
00014 ACE_Thread::keycreate (ACE_thread_key_t *keyp,
00015 #if defined (ACE_HAS_THR_C_DEST)
00016 ACE_THR_C_DEST destructor,
00017 #else
00018 ACE_THR_DEST destructor,
00019 #endif
00020 void *inst)
00021 {
00022
00023 return ACE_OS::thr_keycreate (keyp, destructor, inst);
00024 }
00025
00026
00027
00028 ACE_INLINE int
00029 ACE_Thread::keyfree (ACE_thread_key_t key)
00030 {
00031 ACE_TRACE ("ACE_Thread::keyfree");
00032 return ACE_OS::thr_keyfree (key);
00033 }
00034
00035
00036
00037
00038 ACE_INLINE int
00039 ACE_Thread::setspecific (ACE_thread_key_t key, void *value)
00040 {
00041
00042 return ACE_OS::thr_setspecific (key, value);
00043 }
00044
00045
00046
00047
00048 ACE_INLINE int
00049 ACE_Thread::getspecific (ACE_thread_key_t key, void **valuep)
00050 {
00051
00052 return ACE_OS::thr_getspecific (key, valuep);
00053 }
00054
00055 ACE_INLINE ACE_thread_t
00056 ACE_Thread::self (void)
00057 {
00058
00059 return ACE_OS::thr_self ();
00060 }
00061
00062 ACE_INLINE void
00063 ACE_Thread::exit (ACE_THR_FUNC_RETURN status)
00064 {
00065 ACE_TRACE ("ACE_Thread::exit");
00066 ACE_OS::thr_exit (status);
00067 }
00068
00069 ACE_INLINE void
00070 ACE_Thread::yield (void)
00071 {
00072 ACE_TRACE ("ACE_Thread::yield");
00073 ACE_OS::thr_yield ();
00074 }
00075
00076 ACE_INLINE int
00077 ACE_Thread::spawn (ACE_THR_FUNC func,
00078 void *arg,
00079 long flags,
00080 ACE_thread_t *t_id,
00081 ACE_hthread_t *t_handle,
00082 long priority,
00083 void *thr_stack,
00084 size_t thr_stack_size,
00085 ACE_Thread_Adapter *thread_adapter,
00086 const char** thr_name)
00087 {
00088 ACE_TRACE ("ACE_Thread::spawn");
00089
00090 return ACE_OS::thr_create (func,
00091 arg,
00092 flags,
00093 t_id,
00094 t_handle,
00095 priority,
00096 thr_stack,
00097 thr_stack_size,
00098 thread_adapter,
00099 thr_name);
00100 }
00101
00102 ACE_INLINE int
00103 ACE_Thread::resume (ACE_hthread_t t_id)
00104 {
00105 ACE_TRACE ("ACE_Thread::resume");
00106 return ACE_OS::thr_continue (t_id);
00107 }
00108
00109 ACE_INLINE int
00110 ACE_Thread::suspend (ACE_hthread_t t_id)
00111 {
00112 ACE_TRACE ("ACE_Thread::suspend");
00113 return ACE_OS::thr_suspend (t_id);
00114 }
00115
00116 ACE_INLINE int
00117 ACE_Thread::kill (ACE_thread_t t_id, int signum)
00118 {
00119 ACE_TRACE ("ACE_Thread::kill");
00120 return ACE_OS::thr_kill (t_id, signum);
00121 }
00122
00123 ACE_INLINE int
00124 ACE_Thread::join (ACE_thread_t wait_for,
00125 ACE_thread_t *departed,
00126 ACE_THR_FUNC_RETURN *status)
00127 {
00128 ACE_TRACE ("ACE_Thread::join");
00129 return ACE_OS::thr_join (wait_for, departed, status);
00130 }
00131
00132 ACE_INLINE int
00133 ACE_Thread::join (ACE_hthread_t wait_for,
00134 ACE_THR_FUNC_RETURN *status)
00135 {
00136 ACE_TRACE ("ACE_Thread::join");
00137 return ACE_OS::thr_join (wait_for, status);
00138 }
00139
00140 ACE_INLINE int
00141 ACE_Thread::getconcurrency (void)
00142 {
00143 ACE_TRACE ("ACE_Thread::getconcurrency");
00144 return ACE_OS::thr_getconcurrency ();
00145 }
00146
00147 ACE_INLINE int
00148 ACE_Thread::setconcurrency (int new_level)
00149 {
00150 ACE_TRACE ("ACE_Thread::setconcurrency");
00151 return ACE_OS::thr_setconcurrency (new_level);
00152 }
00153
00154 ACE_INLINE int
00155 ACE_Thread::sigsetmask (int how,
00156 const sigset_t *sigset,
00157 sigset_t *osigset)
00158 {
00159 ACE_TRACE ("ACE_Thread::sigsetmask");
00160 return ACE_OS::thr_sigsetmask (how, sigset, osigset);
00161 }
00162
00163 ACE_INLINE int
00164 ACE_Thread::disablecancel (struct cancel_state *old_state)
00165 {
00166 ACE_TRACE ("ACE_Thread::disablecancel");
00167 int old_cstate = 0;
00168 int result = ACE_OS::thr_setcancelstate (THR_CANCEL_DISABLE,
00169 &old_cstate);
00170 if (result == 0 && old_state != 0)
00171 {
00172 ACE_OS::memset (old_state,
00173 0,
00174 sizeof (old_state));
00175 old_state->cancelstate = old_cstate;
00176 }
00177
00178 return result;
00179 }
00180
00181 ACE_INLINE int
00182 ACE_Thread::enablecancel (struct cancel_state *old_state,
00183 int flag)
00184 {
00185 ACE_TRACE ("ACE_Thread::enablecancel");
00186 int old_cstate = 0;
00187 int old_ctype = 0;
00188 int result;
00189
00190 result = ACE_OS::thr_setcancelstate (THR_CANCEL_ENABLE,
00191 &old_cstate);
00192 if (result != 0)
00193 return result;
00194
00195 result = ACE_OS::thr_setcanceltype (flag,
00196 &old_ctype);
00197 if (result != 0)
00198 return result;
00199
00200 if (old_state != 0)
00201 {
00202 old_state->cancelstate = old_cstate;
00203 old_state->canceltype = old_ctype;
00204 }
00205
00206 return 0;
00207 }
00208
00209 ACE_INLINE int
00210 ACE_Thread::setcancelstate (struct cancel_state &new_state,
00211 struct cancel_state *old_state)
00212 {
00213 ACE_TRACE ("ACE_Thread::setcancelstate");
00214 int old_cstate = 0;
00215 int old_ctype = 0;
00216
00217 if (new_state.cancelstate != 0
00218 && ACE_OS::thr_setcancelstate (new_state.cancelstate,
00219 &old_cstate) != 0)
00220 return -1;
00221
00222 if (new_state.canceltype != 0
00223 && ACE_OS::thr_setcanceltype (new_state.canceltype,
00224 &old_ctype) != 0)
00225 {
00226 int o_cstate;
00227
00228 ACE_OS::thr_setcancelstate (old_cstate,
00229 &o_cstate);
00230 return -1;
00231 }
00232
00233 if (old_state != 0)
00234 {
00235 old_state->cancelstate = old_cstate;
00236 old_state->canceltype = old_ctype;
00237 }
00238
00239 return 0;
00240 }
00241
00242 ACE_INLINE int
00243 ACE_Thread::cancel (ACE_thread_t t_id)
00244 {
00245 ACE_TRACE ("ACE_Thread::cancel");
00246
00247 return ACE_OS::thr_cancel (t_id);
00248 }
00249
00250 ACE_INLINE void
00251 ACE_Thread::testcancel (void)
00252 {
00253 ACE_TRACE ("ACE_Thread::testcancel");
00254
00255 ACE_OS::thr_testcancel ();
00256 }
00257
00258 ACE_INLINE void
00259 ACE_Thread::self (ACE_hthread_t &t_id)
00260 {
00261
00262 ACE_OS::thr_self (t_id);
00263 }
00264
00265 ACE_INLINE int
00266 ACE_Thread::getprio (ACE_hthread_t ht_id, int &priority)
00267 {
00268 ACE_TRACE ("ACE_Thread::getprio");
00269 return ACE_OS::thr_getprio (ht_id, priority);
00270 }
00271
00272 ACE_INLINE int
00273 ACE_Thread::getprio (ACE_hthread_t ht_id, int &priority, int &policy)
00274 {
00275 ACE_TRACE ("ACE_Thread::getprio");
00276 return ACE_OS::thr_getprio (ht_id, priority, policy);
00277 }
00278
00279 ACE_INLINE int
00280 ACE_Thread::setprio (ACE_hthread_t ht_id, int priority, int policy)
00281 {
00282 ACE_TRACE ("ACE_Thread::setprio");
00283 return ACE_OS::thr_setprio (ht_id, priority, policy);
00284 }
00285
00286 ACE_END_VERSIONED_NAMESPACE_DECL