00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef ACE_TOKEN_INVARIANTS_H
00020 #define ACE_TOKEN_INVARIANTS_H
00021 #include "ace/pre.h"
00022
00023 #include "ace/Synch.h"
00024
00025 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00026 # pragma once
00027 #endif
00028
00029 #include "ace/Map_Manager.h"
00030 #include "ace/Local_Tokens.h"
00031
00032 #if defined (ACE_HAS_TOKENS_LIBRARY)
00033
00034
00035
00036
00037
00038
00039
00040
00041 class ACE_Export ACE_Mutex_Invariants
00042 {
00043 public:
00044
00045 ACE_Mutex_Invariants (void);
00046
00047
00048
00049 int acquired (void);
00050
00051
00052 void releasing (void);
00053
00054
00055
00056
00057 ACE_Mutex_Invariants (const ACE_Mutex_Invariants &rhs);
00058
00059
00060 void operator= (const ACE_Mutex_Invariants &rhs);
00061
00062
00063 void dump (void) const;
00064
00065 private:
00066
00067 int owners_;
00068 };
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079 class ACE_Export ACE_RWLock_Invariants
00080 {
00081 public:
00082
00083 ACE_RWLock_Invariants (void);
00084
00085
00086
00087 int writer_acquired (void);
00088
00089
00090
00091 int reader_acquired (void);
00092
00093
00094 void releasing (void);
00095
00096
00097
00098
00099 ACE_RWLock_Invariants (const ACE_RWLock_Invariants &rhs);
00100
00101
00102 void operator= (const ACE_RWLock_Invariants &rhs);
00103
00104
00105 void dump (void) const;
00106
00107 private:
00108
00109 int writers_;
00110
00111
00112 int readers_;
00113 };
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127 class ACE_Export ACE_Token_Invariant_Manager : public ACE_Cleanup
00128 {
00129 public:
00130
00131
00132 static ACE_Token_Invariant_Manager *instance (void);
00133
00134
00135
00136
00137
00138
00139 int acquired (const ACE_Token_Proxy *proxy);
00140
00141
00142 void releasing (const ACE_Token_Proxy *proxy);
00143
00144
00145
00146
00147
00148
00149 int mutex_acquired (const ACE_TCHAR *token_name);
00150
00151
00152 void mutex_releasing (const ACE_TCHAR *token_name);
00153
00154
00155
00156 int reader_acquired (const ACE_TCHAR *token_name);
00157
00158
00159
00160 int writer_acquired (const ACE_TCHAR *token_name);
00161
00162
00163 void rwlock_releasing (const ACE_TCHAR *token_name);
00164
00165
00166 void dump (void) const;
00167
00168
00169
00170
00171 ACE_Token_Invariant_Manager (void);
00172
00173
00174 virtual ~ACE_Token_Invariant_Manager (void);
00175
00176 protected:
00177
00178 int get_mutex (const ACE_TCHAR *token_name,
00179 ACE_Mutex_Invariants *&inv);
00180
00181
00182 int get_rwlock (const ACE_TCHAR *token_name,
00183 ACE_RWLock_Invariants *&inv);
00184
00185
00186 ACE_TOKEN_CONST::MUTEX lock_;
00187
00188
00189 typedef ACE_Token_Name TOKEN_NAME;
00190
00191
00192 typedef ACE_Map_Manager<TOKEN_NAME, ACE_Mutex_Invariants *, ACE_Null_Mutex>
00193 MUTEX_COLLECTION;
00194
00195
00196 typedef ACE_Map_Iterator<TOKEN_NAME, ACE_Mutex_Invariants *, ACE_Null_Mutex>
00197 MUTEX_COLLECTION_ITERATOR;
00198
00199
00200 typedef ACE_Map_Entry<TOKEN_NAME, ACE_Mutex_Invariants *>
00201 MUTEX_COLLECTION_ENTRY;
00202
00203
00204 MUTEX_COLLECTION mutex_collection_;
00205
00206
00207 typedef ACE_Map_Manager<TOKEN_NAME, ACE_RWLock_Invariants *, ACE_Null_Mutex>
00208 RWLOCK_COLLECTION;
00209
00210
00211 typedef ACE_Map_Iterator<TOKEN_NAME, ACE_RWLock_Invariants *, ACE_Null_Mutex>
00212 RWLOCK_COLLECTION_ITERATOR;
00213
00214
00215 typedef ACE_Map_Entry<TOKEN_NAME, ACE_RWLock_Invariants *>
00216 RWLOCK_COLLECTION_ENTRY;
00217
00218
00219 RWLOCK_COLLECTION rwlock_collection_;
00220
00221
00222 static ACE_Token_Invariant_Manager *instance_;
00223 };
00224
00225 #endif
00226
00227 #include "ace/post.h"
00228 #endif