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
163
164
165
166
167
168
169
170
171
172
|
// **********************************************************************
//
// Copyright (c) 2002
// ZeroC, Inc.
// Billerica, MA, USA
//
// All Rights Reserved.
//
// Ice is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License version 2 as published by
// the Free Software Foundation.
//
// **********************************************************************
#ifndef ICE_CONNECTION_H
#define ICE_CONNECTION_H
#include <IceUtil/RecMutex.h>
#include <IceUtil/Monitor.h>
#include <IceUtil/Time.h>
#include <Ice/ConnectionF.h>
#include <Ice/ConnectionFactoryF.h>
#include <Ice/InstanceF.h>
#include <Ice/TransceiverF.h>
#include <Ice/ObjectAdapterF.h>
#include <Ice/ServantManagerF.h>
#include <Ice/EndpointF.h>
#include <Ice/LoggerF.h>
#include <Ice/TraceLevelsF.h>
#include <Ice/OutgoingAsyncF.h>
#include <Ice/EventHandler.h>
namespace Ice
{
class LocalException;
}
namespace IceInternal
{
class Outgoing;
class Connection : public EventHandler, public IceUtil::Monitor<IceUtil::RecMutex>
{
public:
void activate();
void hold();
enum DestructionReason
{
ObjectAdapterDeactivated,
CommunicatorDestroyed
};
void destroy(DestructionReason);
bool isDestroyed() const;
bool isFinished() const;
void waitUntilHolding() const;
void waitUntilFinished() const;
void monitor();
void validate();
void incProxyCount();
void decProxyCount();
void prepareRequest(BasicStream*);
void sendRequest(Outgoing*, bool);
void sendAsyncRequest(const OutgoingAsyncPtr&);
void prepareBatchRequest(BasicStream*);
void finishBatchRequest(BasicStream*);
void abortBatchRequest();
void flushBatchRequest();
void sendResponse(BasicStream*);
void sendNoResponse();
int timeout() const;
EndpointPtr endpoint() const;
void setAdapter(const Ice::ObjectAdapterPtr&);
Ice::ObjectAdapterPtr getAdapter() const;
//
// Operations from EventHandler
//
virtual bool readable() const;
virtual void read(BasicStream&);
virtual void message(BasicStream&, const ThreadPoolPtr&);
virtual void finished(const ThreadPoolPtr&);
virtual void exception(const Ice::LocalException&);
virtual std::string toString() const;
//
// Compare endpoints for sorting purposes.
//
virtual bool operator==(const Connection&) const;
virtual bool operator!=(const Connection&) const;
virtual bool operator<(const Connection&) const;
private:
Connection(const InstancePtr&, const TransceiverPtr&, const EndpointPtr&, const Ice::ObjectAdapterPtr&);
virtual ~Connection();
friend class IncomingConnectionFactory;
friend class OutgoingConnectionFactory;
enum State
{
StateNotValidated,
StateActive,
StateHolding,
StateClosing,
StateClosed
};
void setState(State, const Ice::LocalException&);
void setState(State);
void initiateShutdown() const;
void registerWithPool();
void unregisterWithPool();
static void doCompress(BasicStream&, BasicStream&);
static void doUncompress(BasicStream&, BasicStream&);
TransceiverPtr _transceiver;
const EndpointPtr _endpoint;
Ice::ObjectAdapterPtr _adapter;
ServantManagerPtr _servantManager;
const Ice::LoggerPtr _logger;
const TraceLevelsPtr _traceLevels;
bool _registeredWithPool;
bool _warn;
int _acmTimeout;
IceUtil::Time _acmAbsoluteTimeout;
const std::vector<Ice::Byte> _requestHdr;
const std::vector<Ice::Byte> _requestBatchHdr;
const std::vector<Ice::Byte> _replyHdr;
Ice::Int _nextRequestId;
std::map<Ice::Int, Outgoing*> _requests;
std::map<Ice::Int, Outgoing*>::iterator _requestsHint;
std::map<Ice::Int, OutgoingAsyncPtr> _asyncRequests;
std::map<Ice::Int, OutgoingAsyncPtr>::iterator _asyncRequestsHint;
std::auto_ptr<Ice::LocalException> _exception;
BasicStream _batchStream;
int _batchRequestNum;
int _dispatchCount; // The number of requests currently being dispatched.
int _proxyCount; // The number of proxies using this connection.
State _state;
};
}
#endif
|