#include <Synch_T.h>
Inheritance diagram for ACE_TSS:


Public Methods | |
| ACE_TSS (TYPE *ts_obj=0) | |
| virtual | ~ACE_TSS (void) |
| Deregister with thread-key administration. More... | |
| TYPE * | ts_object (void) const |
| TYPE * | ts_object (TYPE *) |
| Set the thread-specific object for the key associated with this object. More... | |
| TYPE * | operator-> () const |
| Use a "smart pointer" to get the thread-specific object associated with the <key_>. More... | |
| operator TYPE * (void) const | |
| Return or create and return the calling threads TYPE object. More... | |
| virtual TYPE * | make_TSS_TYPE (void) const |
| Hook for construction parameters. More... | |
| void | dump (void) const |
| Dump the state of an object. More... | |
Protected Methods | |
| TYPE * | ts_get (void) const |
| Actually implements the code that retrieves the object from thread-specific storage. More... | |
| int | ts_init (void) const |
| Factors out common code for initializing TSS. This must NOT be called with the lock held... More... | |
| void | operator= (const ACE_TSS< TYPE > &) |
| ACE_TSS (const ACE_TSS< TYPE > &) | |
Protected Attributes | |
| TYPE * | type_ |
| This implementation only works for non-threading systems... More... | |
This class is a wrapper around the OS thread library thread-specific functions. It uses the <C++ operator->> to shield applications from the details of accessing thread-specific storage.
NOTE: For maximal portability, <TYPE> cannot be a built-in type, but instead should be a user-defined class (some compilers will allow a built-in type, others won't). See template class ACE_TSS_Type_Adapter, below, for adapting built-in types to work with ACE_TSS.
Definition at line 223 of file Synch_T.h.
|
||||||||||
|
If caller has passed us a non-NULL ts_obj *, then we'll just use this to initialize the thread-specific value (but only for the calling thread). Thus, subsequent calls to <operator->> in this thread will return this value. This is useful since it enables us to assign objects to thread-specific data that have arbitrarily complex constructors. Definition at line 422 of file Synch_T.i.
00423 : type_ (type) 00424 { 00425 } |
|
||||||||||
|
Deregister with thread-key administration.
Definition at line 242 of file Synch_T.cpp. References ACE_OS::thr_key_detach.
00243 {
00244 // We can't call <ACE_OS::thr_keyfree> until *all* of the threads
00245 // that are using that key have done an <ACE_OS::thr_key_detach>.
00246 // Otherwise, we'll end up with "dangling TSS pointers."
00247 ACE_OS::thr_key_detach (this);
00248 }
|
|
||||||||||
|
|
|
||||||||||
|
Dump the state of an object.
Reimplemented in ACE_TSS_Connection. Definition at line 273 of file Synch_T.cpp. References ACE_BEGIN_DUMP, ACE_DEBUG, ACE_END_DUMP, ACE_LIB_TEXT, and LM_DEBUG. Referenced by ACE_TSS_Connection::dump.
00274 {
00275 // ACE_TRACE ("ACE_TSS<TYPE>::dump");
00276 #if defined (ACE_HAS_THREADS) && (defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) || defined (ACE_HAS_TSS_EMULATION))
00277 ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
00278 this->keylock_.dump ();
00279 ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("key_ = %d\n"), this->key_));
00280 ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\nonce_ = %d"), this->once_));
00281 ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\n")));
00282 ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
00283 #endif /* defined (ACE_HAS_THREADS) && (defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) || defined (ACE_HAS_TSS_EMULATION)) */
00284 }
|
|
||||||||||
|
Hook for construction parameters.
Reimplemented in ACE_TSS_Connection. Definition at line 263 of file Synch_T.cpp. References ACE_NEW_RETURN.
00264 {
00265 TYPE *temp = 0;
00266 ACE_NEW_RETURN (temp,
00267 TYPE,
00268 0);
00269 return temp;
00270 }
|
|
||||||||||
|
Return or create and return the calling threads TYPE object.
Definition at line 257 of file Synch_T.cpp. References ts_get.
00258 {
00259 return this->ts_get ();
00260 }
|
|
|||||||||
|
Use a "smart pointer" to get the thread-specific object associated with the <key_>.
Definition at line 251 of file Synch_T.cpp. References ts_get. Referenced by ACE_TSS_Connection::get_connection.
00252 {
00253 return this->ts_get ();
00254 }
|
|
||||||||||
|
|
|
||||||||||
|
Actually implements the code that retrieves the object from thread-specific storage.
Definition at line 447 of file Synch_T.i. References type_. Referenced by operator TYPE *, and operator->.
00448 {
00449 return this->type_;
00450 }
|
|
||||||||||
|
Factors out common code for initializing TSS. This must NOT be called with the lock held...
Definition at line 428 of file Synch_T.i.
00429 {
00430 return 0;
00431 }
|
|
||||||||||
|
Set the thread-specific object for the key associated with this object.
Definition at line 440 of file Synch_T.i. References type_.
|
|
||||||||||
|
Get the thread-specific object for the key associated with this object. Returns 0 if the data has never been initialized, otherwise returns a pointer to the data. Definition at line 434 of file Synch_T.i. References type_.
00435 {
00436 return this->type_;
00437 }
|
|
|||||
|
This implementation only works for non-threading systems...
|
1.2.14 written by Dimitri van Heesch,
© 1997-2002