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

Local_Tokens.i

Go to the documentation of this file.
00001 /* -*- C++ -*- */
00002 // $Id: Local_Tokens.i,v 1.1.1.3 2001/12/04 14:33:02 chad Exp $
00003 
00004 #if defined (ACE_HAS_TOKENS_LIBRARY)
00005 
00006 ACE_INLINE int
00007 ACE_Token_Proxy::type (void) const
00008 {
00009   ACE_TRACE ("ACE_Token_Proxy::type");
00010   return 0;
00011 }
00012 
00013 ACE_INLINE int
00014 ACE_Token_Proxy::acquire_read (int notify,
00015                                void (*sleep_hook)(void *),
00016                                ACE_Synch_Options &options)
00017 {
00018   return this->acquire (notify,
00019                         sleep_hook,
00020                         options);
00021 }
00022 
00023 ACE_INLINE int
00024 ACE_Token_Proxy::acquire_write (int notify,
00025                                 void (*sleep_hook)(void *),
00026                                 ACE_Synch_Options &options)
00027 {
00028   return this->acquire (notify,
00029                         sleep_hook,
00030                         options);
00031 }
00032 
00033 ACE_INLINE int
00034 ACE_Token_Proxy::tryacquire_read (void (*sleep_hook)(void *))
00035 {
00036   return this->tryacquire (sleep_hook);
00037 }
00038 
00039 ACE_INLINE int
00040 ACE_Token_Proxy::tryacquire_write (void (*sleep_hook)(void *))
00041 {
00042   return this->tryacquire (sleep_hook);
00043 }
00044 
00045 // ************************************************************
00046 
00047 ACE_INLINE int
00048 ACE_Token_Proxy_Queue::size (void)
00049 {
00050   ACE_TRACE ("ACE_Token_Proxy_Queue::size");
00051   return this->size_;
00052 }
00053 
00054 // ************************************************************
00055 
00056 ACE_INLINE int
00057 ACE_TPQ_Entry::waiting (void) const
00058 {
00059   ACE_TRACE ("ACE_TPQ_Entry::waiting");
00060   return waiting_;
00061 }
00062 
00063 ACE_INLINE void
00064 ACE_TPQ_Entry::waiting (int v)
00065 {
00066   ACE_TRACE ("ACE_TPQ_Entry::waiting");
00067   waiting_ = v;
00068 }
00069 
00070 ACE_INLINE const ACE_TCHAR *
00071 ACE_TPQ_Entry::client_id (void) const
00072 {
00073   ACE_TRACE ("ACE_TPQ_Entry::client_id");
00074   return this->client_id_;
00075 }
00076 
00077 ACE_INLINE ACE_Token_Proxy *
00078 ACE_TPQ_Entry::proxy (void) const
00079 {
00080   ACE_TRACE ("ACE_TPQ_Entry::proxy");
00081   return this->proxy_;
00082 }
00083 
00084 ACE_INLINE void
00085 ACE_TPQ_Entry::proxy (ACE_Token_Proxy *proxy)
00086 {
00087   ACE_TRACE ("ACE_TPQ_Entry::proxy");
00088   this->proxy_ = proxy;
00089 }
00090 
00091 ACE_INLINE
00092 ACE_TSS_TPQ_Entry::~ACE_TSS_TPQ_Entry (void)
00093 {
00094 }
00095 
00096 ACE_INLINE
00097 ACE_TPQ_Iterator::~ACE_TPQ_Iterator (void)
00098 {
00099 }
00100 
00101 ACE_INLINE
00102 ACE_Token_Proxy_Queue::~ACE_Token_Proxy_Queue (void)
00103 {
00104 }
00105 
00106 ACE_INLINE
00107 ACE_Tokens::~ACE_Tokens (void)
00108 {
00109 }
00110 
00111 ACE_INLINE void
00112 ACE_Tokens::remove (ACE_TPQ_Entry *caller)
00113 {
00114   this->waiters_.remove (caller);
00115 }
00116 
00117 ACE_INLINE int
00118 ACE_Tokens::dec_reference (void)
00119 {
00120   ACE_TRACE ("ACE_Tokens::dec_reference");
00121   if (this->reference_count_ == 0)
00122     {
00123       ACE_DEBUG ((LM_DEBUG,  ACE_LIB_TEXT ("dec_reference already zero")));
00124       return 0;
00125     }
00126 
00127   return --this->reference_count_;
00128 }
00129 
00130 ACE_INLINE void
00131 ACE_Tokens::inc_reference (void)
00132 {
00133   ACE_TRACE ("ACE_Tokens::inc_reference");
00134   ++this->reference_count_;
00135 }
00136 
00137 ACE_INLINE ACE_Token_Proxy_Queue *
00138 ACE_Tokens::waiters ()
00139 {
00140   ACE_TRACE ("ACE_Tokens::waiters");
00141   return &this->waiters_;
00142 }
00143 
00144 ACE_INLINE int
00145 ACE_Tokens::no_of_waiters ()
00146 {
00147   ACE_TRACE ("ACE_Tokens::no_of_waiters");
00148   return this->waiters_.size ();
00149 }
00150 
00151 ACE_INLINE const ACE_TPQ_Entry *
00152 ACE_Token_Proxy_Queue::head (void)
00153 {
00154   ACE_TRACE ("ACE_Token_Proxy_Queue::head");
00155   if (this->head_ == 0)
00156     return 0;
00157   else
00158     return this->head_;
00159 }
00160 
00161 // **************************************************
00162 // **************************************************
00163 // **************************************************
00164 
00165 ACE_INLINE void
00166 ACE_Tokens::visit (int v)
00167 {
00168   ACE_TRACE ("ACE_Tokens::visit");
00169   visited_ = v;
00170 }
00171 
00172 ACE_INLINE int
00173 ACE_Tokens::visited (void)
00174 {
00175   ACE_TRACE ("ACE_Tokens::visited");
00176   return visited_;
00177 }
00178 
00179 ACE_INLINE ACE_TPQ_Entry *
00180 ACE_Tokens::owner (void)
00181 {
00182   ACE_TRACE ("ACE_Tokens::owner");
00183   return (ACE_TPQ_Entry *) this->waiters_.head ();
00184 }
00185 
00186 ACE_INLINE const ACE_TCHAR*
00187 ACE_Tokens::owner_id ()
00188 {
00189   ACE_TRACE ("ACE_Tokens::owner_id");
00190   if (this->owner () == 0)
00191     return ACE_LIB_TEXT ("no owner");
00192   else
00193     return this->owner ()->client_id ();
00194 }
00195 
00196 ACE_INLINE const ACE_TCHAR*
00197 ACE_Tokens::name (void)
00198 {
00199   ACE_TRACE ("ACE_Tokens::name");
00200   return this->token_name_;
00201 }
00202 
00203 #if 0
00204 ACE_INLINE ACE_Token_Proxy *
00205 ACE_Tokens::current_owner (void)
00206 {
00207   ACE_TRACE ("ACE_Tokens::current_owner");
00208   // ACE_GUARD_RETURN ???
00209 
00210   if (this->owner () == 0)
00211     return 0;
00212   else
00213     return this->owner ()->proxy ();
00214 }
00215 #endif /* 0 */
00216 
00217 // ************************************************************
00218 
00219 ACE_INLINE int
00220 ACE_Mutex_Token::type (void) const
00221 {
00222   ACE_TRACE ("ACE_Mutex_Token::type");
00223   return (int) ACE_Tokens::MUTEX;
00224 }
00225 
00226 // ************************************************************
00227 
00228 ACE_INLINE int
00229 ACE_RW_Token::type (void) const
00230 {
00231   ACE_TRACE ("ACE_RW_Token::type");
00232   return (int) ACE_Tokens::RWLOCK;
00233 }
00234 
00235 // ************************************************************
00236 
00237 ACE_INLINE int
00238 ACE_TPQ_Entry::nesting_level (void) const
00239 {
00240   ACE_TRACE ("ACE_TPQ_Entry::nesting_level");
00241   return this->nesting_level_;
00242 }
00243 
00244 ACE_INLINE void
00245 ACE_TPQ_Entry::nesting_level (int delta)
00246 {
00247   ACE_TRACE ("ACE_TPQ_Entry::nesting_level");
00248   this->nesting_level_ += delta;
00249 }
00250 
00251 ACE_INLINE ACE_TPQ_Entry::PTVF
00252 ACE_TPQ_Entry::sleep_hook (void) const
00253 {
00254   ACE_TRACE ("ACE_TPQ_Entry::sleep_hook");
00255   return this->sleep_hook_;
00256 }
00257 
00258 ACE_INLINE void
00259 ACE_TPQ_Entry::sleep_hook (void (*sh)(void *))
00260 {
00261   ACE_TRACE ("ACE_TPQ_Entry::sleep_hook");
00262   this->sleep_hook_ = sh;
00263 }
00264 
00265 ACE_INLINE void
00266 ACE_TPQ_Entry::call_sleep_hook (void)
00267 {
00268   ACE_TRACE ("ACE_TPQ_Entry::call_sleep_hook");
00269 
00270   // if a function has been registered, call it.
00271   if (this->sleep_hook () != 0)
00272     this->sleep_hook () ((void *) this->proxy ());
00273   else
00274     // otherwise, call back the sleep_hook method
00275     this->proxy ()->sleep_hook ();
00276 }
00277 
00278 ACE_INLINE int
00279 ACE_TPQ_Entry::equal_client_id (const ACE_TCHAR *id)
00280 {
00281   ACE_TRACE ("ACE_TPQ_Entry::equal_client_id");
00282   return (ACE_OS::strcmp (this->client_id (), id) == 0);
00283 }
00284 
00285 // ************************************************************
00286 // ************************************************************
00287 // ************************************************************
00288 
00289 ACE_INLINE
00290 ACE_Local_Mutex::ACE_Local_Mutex (const ACE_TCHAR *token_name,
00291                                   int ignore_deadlock,
00292                                   int debug)
00293 {
00294   ACE_TRACE ("ACE_Local_Mutex::ACE_Local_Mutex");
00295   this->open (token_name, ignore_deadlock, debug);
00296 }
00297 
00298 ACE_INLINE void
00299 ACE_Token_Name::name (const ACE_TCHAR *new_name)
00300 {
00301   ACE_TRACE ("ACE_Token_Name::name");
00302 
00303   if (new_name == 0)
00304     new_name = ACE_LIB_TEXT ("no name");
00305 
00306   int n = ACE_OS::strlen (new_name) + 1;
00307 
00308   if (n >= ACE_MAXTOKENNAMELEN)
00309     n = ACE_MAXTOKENNAMELEN - 1;
00310 
00311   ACE_OS::strsncpy (this->token_name_, (ACE_TCHAR *) new_name, n);
00312 }
00313 
00314 ACE_INLINE const ACE_TCHAR*
00315 ACE_Token_Name::name (void) const
00316 {
00317   ACE_TRACE ("ACE_Token_Name::name");
00318   return this->token_name_;
00319 }
00320 
00321 ACE_INLINE ACE_Token_Proxy *
00322 ACE_Local_Mutex::clone (void) const
00323 {
00324   ACE_Token_Proxy *temp = 0;
00325   ACE_NEW_RETURN (temp,
00326                   ACE_Local_Mutex (token_->name (),
00327                                    ignore_deadlock_,
00328                                    debug_),
00329                   0);
00330   return temp;
00331 }
00332 
00333 ACE_INLINE ACE_Tokens *
00334 ACE_Local_Mutex::create_token (const ACE_TCHAR *name)
00335 {
00336   ACE_Tokens *temp = 0;
00337   ACE_NEW_RETURN (temp,
00338                   ACE_Mutex_Token (name),
00339                   0);
00340   return temp;
00341 }
00342 
00343 ACE_INLINE
00344 ACE_Local_Mutex::~ACE_Local_Mutex (void)
00345 {
00346 }
00347 
00348 // ************************************************************
00349 
00350 ACE_INLINE
00351 ACE_Local_RLock::ACE_Local_RLock (const ACE_TCHAR *token_name,
00352                                   int ignore_deadlock,
00353                                   int debug)
00354 {
00355   ACE_TRACE ("ACE_Local_RLock::ACE_Local_RLock");
00356   this->open (token_name, ignore_deadlock, debug);
00357 }
00358 
00359 ACE_INLINE
00360 ACE_Local_RLock::~ACE_Local_RLock (void)
00361 {
00362 }
00363 
00364 ACE_INLINE ACE_Tokens *
00365 ACE_Local_RLock::create_token (const ACE_TCHAR *name)
00366 {
00367   ACE_Tokens *temp = 0;
00368   ACE_NEW_RETURN (temp,
00369                   ACE_RW_Token (name),
00370                   0);
00371   return temp;
00372 }
00373 
00374 ACE_INLINE int
00375 ACE_Local_RLock::type (void) const
00376 {
00377   return ACE_RW_Token::READER;
00378 }
00379 
00380 ACE_INLINE ACE_Token_Proxy *
00381 ACE_Local_RLock::clone (void) const
00382 {
00383   ACE_Token_Proxy *temp = 0; 
00384   ACE_NEW_RETURN (temp,
00385                   ACE_Local_RLock (token_->name (),
00386                                    ignore_deadlock_,
00387                                    debug_),
00388                   0);
00389   return temp;
00390 }
00391 
00392 // ************************************************************
00393 
00394 ACE_INLINE
00395 ACE_Local_WLock::ACE_Local_WLock (const ACE_TCHAR *token_name,
00396                                   int ignore_deadlock,
00397                                   int debug)
00398 {
00399   ACE_TRACE ("ACE_Local_WLock::ACE_Local_WLock");
00400   this->open (token_name, ignore_deadlock, debug);
00401 }
00402 
00403 ACE_INLINE
00404 ACE_Local_WLock::~ACE_Local_WLock (void)
00405 {
00406 }
00407 
00408 ACE_INLINE ACE_Tokens *
00409 ACE_Local_WLock::create_token (const ACE_TCHAR *name)
00410 {
00411   ACE_Tokens *temp = 0;
00412   ACE_NEW_RETURN (temp,
00413                   ACE_RW_Token (name),
00414                   0);
00415   return temp;
00416 }
00417 
00418 ACE_INLINE int
00419 ACE_Local_WLock::type (void) const
00420 {
00421   return ACE_RW_Token::WRITER;
00422 }
00423 
00424 ACE_INLINE ACE_Token_Proxy *
00425 ACE_Local_WLock::clone (void) const
00426 {
00427   ACE_Token_Proxy *temp = 0;
00428   ACE_NEW_RETURN (temp,
00429                   ACE_Local_WLock (token_->name (),
00430                                    ignore_deadlock_,
00431                                    debug_),
00432                   0);
00433   return temp;
00434 }
00435 
00436 // ************************************************************
00437 
00438 
00439 ACE_INLINE void
00440 ACE_Token_Name::operator= (const ACE_Token_Name &rhs)
00441 {
00442   ACE_TRACE ("ACE_Token_Name::operator=");
00443   if (&rhs == this)
00444     return;
00445   else
00446     this->name (rhs.name ());
00447 }
00448 
00449 ACE_INLINE int
00450 ACE_Token_Name::operator== (const ACE_Token_Name &rhs) const
00451 {
00452   ACE_TRACE ("ACE_Token_Name::operator==");
00453 
00454   // the name and type must be the same
00455   return (ACE_OS::strcmp (this->token_name_, rhs.name ()) == 0);
00456 }
00457 
00458 #endif /* ACE_HAS_TOKENS_LIBRARY */

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