#include <Token_Invariants.h>
Inheritance diagram for ACE_Token_Invariant_Manager:


| Public Member Functions | |
| int | acquired (const ACE_Token_Proxy *proxy) | 
| void | releasing (const ACE_Token_Proxy *proxy) | 
| Updates internal database. | |
| int | mutex_acquired (const ACE_TCHAR *token_name) | 
| void | mutex_releasing (const ACE_TCHAR *token_name) | 
| Updates internal database. | |
| int | reader_acquired (const ACE_TCHAR *token_name) | 
| int | writer_acquired (const ACE_TCHAR *token_name) | 
| void | rwlock_releasing (const ACE_TCHAR *token_name) | 
| Updates internal database. | |
| void | dump (void) const | 
| Dump the state of the class. | |
| ACE_Token_Invariant_Manager (void) | |
| Prevent non-singleton construction. | |
| virtual | ~ACE_Token_Invariant_Manager (void) | 
| Destruction. | |
| Static Public Member Functions | |
| ACE_Token_Invariant_Manager * | instance (void) | 
| Singleton access point. | |
| Protected Types | |
| typedef ACE_Token_Name | TOKEN_NAME | 
| This may be changed to a template type. | |
| typedef ACE_Map_Manager< TOKEN_NAME, ACE_Mutex_Invariants *, ACE_Null_Mutex > | MUTEX_COLLECTION | 
| COLLECTION maintains a mapping from token names to mutexes. | |
| typedef MUTEX_COLLECTION::ITERATOR | MUTEX_COLLECTION_ITERATOR | 
| Allows iterations through collection. | |
| typedef MUTEX_COLLECTION::ENTRY | MUTEX_COLLECTION_ENTRY | 
| Allows iterations through collection. | |
| typedef ACE_Map_Manager< TOKEN_NAME, ACE_RWLock_Invariants *, ACE_Null_Mutex > | RWLOCK_COLLECTION | 
| COLLECTION maintains a mapping from token names to mutexes. | |
| typedef RWLOCK_COLLECTION::ITERATOR | RWLOCK_COLLECTION_ITERATOR | 
| Allows iterations through collection. | |
| typedef RWLOCK_COLLECTION::ENTRY | RWLOCK_COLLECTION_ENTRY | 
| Allows iterations through collection. | |
| Protected Member Functions | |
| int | get_mutex (const ACE_TCHAR *token_name, ACE_Mutex_Invariants *&inv) | 
| Return or create. | |
| int | get_rwlock (const ACE_TCHAR *token_name, ACE_RWLock_Invariants *&inv) | 
| Return or create. | |
| Protected Attributes | |
| ACE_TOKEN_CONST::MUTEX | lock_ | 
| ACE_Mutex_Token used to lock internal data structures. | |
| MUTEX_COLLECTION | mutex_collection_ | 
| MUTEX_COLLECTION maintains a mapping from token names to mutexes. | |
| RWLOCK_COLLECTION | rwlock_collection_ | 
| MUTEX_COLLECTION maintains a mapping from token names to mutexes. | |
| Static Protected Attributes | |
| ACE_Token_Invariant_Manager * | instance_ = 0 | 
| Singleton pointer. | |
The Token Invariant Manager allows applications to test that invariants are always satisfied. Currently, Token_Invariants can test mutexes and readers/writer locks. Does not test recursive acquisition. Note that this class does not ever clean its database. Until destroyed, it's size will forever increase.
Definition at line 130 of file Token_Invariants.h.
| 
 | 
| COLLECTION maintains a mapping from token names to mutexes. 
 Definition at line 196 of file Token_Invariants.h. | 
| 
 | 
| Allows iterations through collection. 
 
 Definition at line 210 of file Token_Invariants.h. | 
| 
 | 
| Allows iterations through collection. 
 
 Definition at line 203 of file Token_Invariants.h. | 
| 
 | 
| COLLECTION maintains a mapping from token names to mutexes. 
 Definition at line 217 of file Token_Invariants.h. | 
| 
 | 
| Allows iterations through collection. 
 
 Definition at line 231 of file Token_Invariants.h. | 
| 
 | 
| Allows iterations through collection. 
 
 Definition at line 224 of file Token_Invariants.h. | 
| 
 | 
| This may be changed to a template type. 
 Definition at line 192 of file Token_Invariants.h. | 
| 
 | 
| Prevent non-singleton construction. 
 Definition at line 41 of file Token_Invariants.cpp. References ACE_TRACE. 
 00042 {
00043   ACE_TRACE ("ACE_Token_Invariant_Manager::ACE_Token_Invariant_Manager");
00044 }
 | 
| 
 | 
| Destruction. 
 Definition at line 208 of file Token_Invariants.cpp. References ACE_TRACE, mutex_collection_, and rwlock_collection_. 
 00209 {
00210   ACE_TRACE ("ACE_Token_Invariant_Manager::~ACE_Token_Invariant_Manager");
00211 
00212   MUTEX_COLLECTION::ITERATOR iterator (mutex_collection_);
00213 
00214   for (MUTEX_COLLECTION::ENTRY *temp = 0;
00215        iterator.next (temp) != 0;
00216        iterator.advance ())
00217     delete temp->int_id_;
00218 
00219   RWLOCK_COLLECTION::ITERATOR iterator2 (rwlock_collection_);
00220 
00221   for (RWLOCK_COLLECTION::ENTRY *temp2 = 0;
00222        iterator2.next (temp2) != 0;
00223        iterator2.advance ())
00224     delete temp2->int_id_;
00225 }
 | 
| 
 | 
| Returns 1 on success, 0 when an invariant has been violated and -1 on error. Definition at line 61 of file Token_Invariants.cpp. References ACE_TRACE, mutex_acquired(), ACE_Token_Proxy::name(), reader_acquired(), ACE_Token_Proxy::token_, ACE_Token_Proxy::type(), ACE_Tokens::type(), and writer_acquired(). 
 00062 {
00063   ACE_TRACE ("ACE_Token_Invariant_Manager::acquired");
00064 
00065   // Reach into the proxy to find the token type.
00066   if (proxy->token_->type () == ACE_Tokens::MUTEX)
00067     return this->mutex_acquired (proxy->name ());
00068   else // ACE_Tokens::RWLOCK.
00069     {
00070       if (proxy->type () == ACE_RW_Token::READER)
00071         return this->reader_acquired (proxy->name ());
00072       else // ACE_RW_Token::WRITER.
00073         return this->writer_acquired (proxy->name ());
00074     }
00075 }
 | 
| 
 | 
| Dump the state of the class. 
 Definition at line 140 of file Token_Invariants.cpp. References ACE_BEGIN_DUMP, ACE_DEBUG, ACE_END_DUMP, ACE_LIB_TEXT, ACE_TRACE, ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::dump(), LM_DEBUG, mutex_collection_, and rwlock_collection_. 
 00141 {
00142 #if defined (ACE_HAS_DUMP)
00143   ACE_TRACE ("ACE_Token_Invariant_Manager::dump");
00144   ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
00145   ACE_DEBUG ((LM_DEBUG,  ACE_LIB_TEXT ("mutex_collection_:\n")));
00146   mutex_collection_.dump ();
00147   ACE_DEBUG ((LM_DEBUG,  ACE_LIB_TEXT ("rwlock_collection_:\n")));
00148   rwlock_collection_.dump ();
00149   ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
00150 #endif /* ACE_HAS_DUMP */
00151 }
 | 
| 
 | ||||||||||||
| Return or create. 
 Definition at line 155 of file Token_Invariants.cpp. References ACE_NEW_RETURN, ACE_TCHAR, ACE_TRACE, ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::bind(), ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::find(), and mutex_collection_. Referenced by mutex_acquired(), and mutex_releasing(). 
 00157 {
00158   ACE_TRACE ("ACE_Token_Invariant_Manager::get_mutex");
00159   TOKEN_NAME name (token_name);
00160   if (mutex_collection_.find (name, inv) == -1)
00161     // We did not find one in the collection.
00162     {
00163       ACE_Mutex_Invariants *new_invariant;
00164 
00165       ACE_NEW_RETURN (new_invariant,
00166                       ACE_Mutex_Invariants,
00167                       -1);
00168       if (mutex_collection_.bind (name, new_invariant) == -1)
00169         {
00170           delete new_invariant;
00171           return -1;
00172         }
00173 
00174       if (mutex_collection_.find (name, inv) == -1)
00175         // We did not find one in the collection.
00176         return -1;
00177     }
00178 
00179   return 0;
00180 }
 | 
| 
 | ||||||||||||
| Return or create. 
 Definition at line 183 of file Token_Invariants.cpp. References ACE_NEW_RETURN, ACE_TCHAR, ACE_TRACE, ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::bind(), ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::find(), and rwlock_collection_. Referenced by reader_acquired(), rwlock_releasing(), and writer_acquired(). 
 00185 {
00186   ACE_TRACE ("ACE_Token_Invariant_Manager::get_rwlock");
00187   TOKEN_NAME name (token_name);
00188   if (rwlock_collection_.find (name, inv) == -1)
00189     // We did not find one in the collection.
00190     {
00191       ACE_RWLock_Invariants *new_invariant;
00192 
00193       ACE_NEW_RETURN (new_invariant,
00194                       ACE_RWLock_Invariants,
00195                       -1);
00196       if (rwlock_collection_.bind (name, new_invariant) == -1)
00197         return -1;
00198 
00199       if (rwlock_collection_.find (name, inv) == -1)
00200         // We did not find one in the collection.
00201         return -1;
00202     }
00203 
00204   return 0;
00205 }
 | 
| 
 | 
| Singleton access point. 
 Definition at line 16 of file Token_Invariants.cpp. References ACE_GUARD_RETURN, ACE_NEW_RETURN, ACE_TRACE, ACE_Object_Manager::at_exit(), instance_, and ACE_TOKEN_CONST::MUTEX. 
 00017 {
00018   ACE_TRACE ("ACE_Token_Invariant_Manager::instance");
00019 
00020   // Perform the Double-Check pattern...
00021   if (instance_ == 0)
00022     {
00023       ACE_MT (ACE_TOKEN_CONST::MUTEX *lock =
00024         ACE_Managed_Object<ACE_TOKEN_CONST::MUTEX>::get_preallocated_object
00025           (ACE_Object_Manager::ACE_TOKEN_INVARIANTS_CREATION_LOCK);
00026         ACE_GUARD_RETURN (ACE_TOKEN_CONST::MUTEX, ace_mon, *lock, 0));
00027 
00028       if (instance_ == 0)
00029         {
00030           ACE_NEW_RETURN (instance_,
00031                           ACE_Token_Invariant_Manager,
00032                           0);
00033           // Register for destruction with ACE_Object_Manager.
00034           ACE_Object_Manager::at_exit (instance_);
00035         }
00036     }
00037 
00038   return instance_;
00039 }
 | 
| 
 | 
| Returns 1 on success, 0 when an invariant has been violated and -1 on error. Definition at line 47 of file Token_Invariants.cpp. References ACE_GUARD_RETURN, ACE_TCHAR, ACE_TRACE, ACE_Mutex_Invariants::acquired(), get_mutex(), and ACE_TOKEN_CONST::MUTEX. Referenced by acquired(). 
 00048 {
00049   ACE_TRACE ("ACE_Token_Invariant_Manager::mutex_acquired");
00050 
00051   ACE_GUARD_RETURN (ACE_TOKEN_CONST::MUTEX, ace_mon, this->lock_, -1);
00052 
00053   ACE_Mutex_Invariants *inv = 0;
00054   if (this->get_mutex (token_name, inv) == -1)
00055     return -1;
00056 
00057   return inv->acquired ();
00058 }
 | 
| 
 | 
| Updates internal database. 
 Definition at line 90 of file Token_Invariants.cpp. References ACE_GUARD, ACE_TCHAR, ACE_TRACE, get_mutex(), ACE_TOKEN_CONST::MUTEX, and ACE_Mutex_Invariants::releasing(). Referenced by releasing(). 
 00091 {
00092   ACE_TRACE ("ACE_Token_Invariant_Manager::mutex_releasing");
00093   ACE_GUARD (ACE_TOKEN_CONST::MUTEX, ace_mon, this->lock_);
00094 
00095   ACE_Mutex_Invariants *inv = 0;
00096   if (this->get_mutex (token_name, inv) == 0)
00097     inv->releasing ();
00098 }
 | 
| 
 | 
| Returns 1 on success, 0 when an invariant has been violated and -1 on error. Definition at line 101 of file Token_Invariants.cpp. References ACE_GUARD_RETURN, ACE_TCHAR, ACE_TRACE, get_rwlock(), ACE_TOKEN_CONST::MUTEX, and ACE_RWLock_Invariants::reader_acquired(). Referenced by acquired(). 
 00102 {
00103   ACE_TRACE ("ACE_Token_Invariant_Manager::reader_acquired");
00104   ACE_GUARD_RETURN (ACE_TOKEN_CONST::MUTEX, ace_mon, this->lock_, -1);
00105 
00106   ACE_RWLock_Invariants *inv = 0;
00107   if (this->get_rwlock (token_name, inv) == -1)
00108     return -1;
00109 
00110   return inv->reader_acquired ();
00111 }
 | 
| 
 | 
| Updates internal database. 
 Definition at line 78 of file Token_Invariants.cpp. References ACE_TRACE, mutex_releasing(), ACE_Token_Proxy::name(), rwlock_releasing(), ACE_Token_Proxy::token_, and ACE_Tokens::type(). 
 00079 {
00080   ACE_TRACE ("ACE_Token_Invariant_Manager::releasing");
00081 
00082   // Reach into the proxy to find the token type.
00083   if (proxy->token_->type () == ACE_Tokens::MUTEX)
00084     this->mutex_releasing (proxy->name ());
00085   else // ACE_Tokens::RWLOCK.
00086     this->rwlock_releasing (proxy->name ());
00087 }
 | 
| 
 | 
| Updates internal database. 
 Definition at line 128 of file Token_Invariants.cpp. References ACE_GUARD, ACE_TCHAR, ACE_TRACE, get_rwlock(), ACE_TOKEN_CONST::MUTEX, and ACE_RWLock_Invariants::releasing(). Referenced by releasing(). 
 00129 {
00130   ACE_TRACE ("ACE_Token_Invariant_Manager::rwlock_releasing");
00131 
00132   ACE_GUARD (ACE_TOKEN_CONST::MUTEX, ace_mon, this->lock_);
00133 
00134   ACE_RWLock_Invariants *inv = 0;
00135   if (this->get_rwlock (token_name, inv) == 0)
00136     inv->releasing ();
00137 }
 | 
| 
 | 
| Returns 1 on success, 0 when an invariant has been violated and -1 on error. Definition at line 114 of file Token_Invariants.cpp. References ACE_GUARD_RETURN, ACE_TCHAR, ACE_TRACE, get_rwlock(), ACE_TOKEN_CONST::MUTEX, and ACE_RWLock_Invariants::writer_acquired(). Referenced by acquired(). 
 00115 {
00116   ACE_TRACE ("ACE_Token_Invariant_Manager::writer_acquired");
00117 
00118   ACE_GUARD_RETURN (ACE_TOKEN_CONST::MUTEX, ace_mon, this->lock_, -1);
00119 
00120   ACE_RWLock_Invariants *inv = 0;
00121   if (this->get_rwlock (token_name, inv) == -1)
00122     return -1;
00123 
00124   return inv->writer_acquired ();
00125 }
 | 
| 
 | 
| Singleton pointer. 
 Definition at line 13 of file Token_Invariants.cpp. Referenced by instance(). | 
| 
 | 
| ACE_Mutex_Token used to lock internal data structures. 
 Definition at line 189 of file Token_Invariants.h. | 
| 
 | 
| MUTEX_COLLECTION maintains a mapping from token names to mutexes. 
 Definition at line 213 of file Token_Invariants.h. Referenced by dump(), get_mutex(), and ~ACE_Token_Invariant_Manager(). | 
| 
 | 
| MUTEX_COLLECTION maintains a mapping from token names to mutexes. 
 Definition at line 234 of file Token_Invariants.h. Referenced by dump(), get_rwlock(), and ~ACE_Token_Invariant_Manager(). | 
 1.3.6
 
1.3.6