blob: c708a33f9449636f585b6c34d31fa5034fb944da (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
|
// **********************************************************************
//
// Copyright (c) 2003-2011 ZeroC, Inc. All rights reserved.
//
// This copy of Ice is licensed to you under the terms described in the
// ICE_LICENSE file included in this distribution.
//
// **********************************************************************
#ifndef FREEZE_CONNECTIONI_H
#define FREEZE_CONNECTIONI_H
#include <Freeze/Connection.h>
#include <Freeze/Initialize.h>
#include <Freeze/TransactionI.h>
#include <Freeze/SharedDbEnv.h>
#include <list>
namespace Freeze
{
class MapHelperI;
//
// A mutex shared by a connection and all its transactions
// (for refcounting thread-safety)
//
struct SharedMutex : public IceUtil::Shared
{
IceUtil::Mutex mutex;
};
typedef IceUtil::Handle<SharedMutex> SharedMutexPtr;
class ConnectionI : public Connection
{
public:
virtual TransactionPtr beginTransaction();
virtual TransactionPtr currentTransaction() const;
virtual void removeMapIndex(const std::string&, const std::string&);
virtual void close();
virtual Ice::CommunicatorPtr getCommunicator() const;
virtual std::string getName() const;
//
// Custom refcounting implementation
//
virtual void __incRef();
virtual void __decRef();
virtual int __getRef() const;
virtual ~ConnectionI();
ConnectionI(const SharedDbEnvPtr&);
TransactionIPtr beginTransactionI();
void closeAllIterators();
void registerMap(MapHelperI*);
void unregisterMap(MapHelperI*);
void clearTransaction();
DbTxn* dbTxn() const;
const SharedDbEnvPtr& dbEnv() const;
const Ice::CommunicatorPtr& communicator() const;
const std::string& envName() const;
Ice::Int trace() const;
Ice::Int txTrace() const;
bool deadlockWarning() const;
private:
friend class TransactionI;
int __getRefNoSync() const;
const Ice::CommunicatorPtr _communicator;
SharedDbEnvPtr _dbEnv;
const std::string _envName;
TransactionIPtr _transaction;
std::list<MapHelperI*> _mapList;
const Ice::Int _trace;
const Ice::Int _txTrace;
const bool _deadlockWarning;
SharedMutexPtr _refCountMutex;
int _refCount;
};
typedef IceUtil::Handle<ConnectionI> ConnectionIPtr;
inline void
ConnectionI::clearTransaction()
{
_transaction = 0;
}
inline DbTxn*
ConnectionI::dbTxn() const
{
if(!_transaction)
{
return 0;
}
else
{
return _transaction->dbTxn();
}
}
inline const SharedDbEnvPtr&
ConnectionI::dbEnv() const
{
return _dbEnv;
}
inline const std::string&
ConnectionI::envName() const
{
return _envName;
}
inline const Ice::CommunicatorPtr&
ConnectionI::communicator() const
{
return _communicator;
}
inline Ice::Int
ConnectionI::trace() const
{
return _trace;
}
inline Ice::Int
ConnectionI::txTrace() const
{
return _txTrace;
}
inline bool
ConnectionI::deadlockWarning() const
{
return _deadlockWarning;
}
}
#endif
|