Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

Thread.i

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

Generated on Mon Jun 16 11:21:45 2003 for ACE by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002