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