You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by br...@apache.org on 2011/08/29 20:01:24 UTC
svn commit: r1162920 - /thrift/trunk/lib/cpp/src/server/TNonblockingServer.h
Author: bryanduxbury
Date: Mon Aug 29 18:01:24 2011
New Revision: 1162920
URL: http://svn.apache.org/viewvc?rev=1162920&view=rev
Log:
THRIFT-1301. cpp: consolidate common code in TNonblockingServer constructors
Patch: Adam Simpkins
Modified:
thrift/trunk/lib/cpp/src/server/TNonblockingServer.h
Modified: thrift/trunk/lib/cpp/src/server/TNonblockingServer.h
URL: http://svn.apache.org/viewvc/thrift/trunk/lib/cpp/src/server/TNonblockingServer.h?rev=1162920&r1=1162919&r2=1162920&view=diff
==============================================================================
--- thrift/trunk/lib/cpp/src/server/TNonblockingServer.h (original)
+++ thrift/trunk/lib/cpp/src/server/TNonblockingServer.h Mon Aug 29 18:01:24 2011
@@ -227,91 +227,64 @@ class TNonblockingServer : public TServe
*/
void handleEvent(int fd, short which);
+ void init(int port) {
+ serverSocket_ = -1;
+ port_ = port;
+ threadPoolProcessing_ = false;
+ eventBase_ = NULL;
+ ownEventBase_ = false;
+ numTConnections_ = 0;
+ numActiveProcessors_ = 0;
+ connectionStackLimit_ = CONNECTION_STACK_LIMIT;
+ maxActiveProcessors_ = MAX_ACTIVE_PROCESSORS;
+ maxConnections_ = MAX_CONNECTIONS;
+ taskExpireTime_ = 0;
+ overloadHysteresis_ = 0.8;
+ overloadAction_ = T_OVERLOAD_NO_ACTION;
+ writeBufferDefaultSize_ = WRITE_BUFFER_DEFAULT_SIZE;
+ idleReadBufferLimit_ = IDLE_READ_BUFFER_LIMIT;
+ idleWriteBufferLimit_ = IDLE_WRITE_BUFFER_LIMIT;
+ resizeBufferEveryN_ = RESIZE_BUFFER_EVERY_N;
+ overloaded_ = false;
+ nConnectionsDropped_ = 0;
+ nTotalConnectionsDropped_ = 0;
+ }
+
public:
- TNonblockingServer(boost::shared_ptr<TProcessor> processor,
+ TNonblockingServer(const boost::shared_ptr<TProcessor>& processor,
int port) :
- TServer(processor),
- serverSocket_(-1),
- port_(port),
- threadPoolProcessing_(false),
- eventBase_(NULL),
- ownEventBase_(false),
- numTConnections_(0),
- numActiveProcessors_(0),
- connectionStackLimit_(CONNECTION_STACK_LIMIT),
- maxActiveProcessors_(MAX_ACTIVE_PROCESSORS),
- maxConnections_(MAX_CONNECTIONS),
- taskExpireTime_(0),
- overloadHysteresis_(0.8),
- overloadAction_(T_OVERLOAD_NO_ACTION),
- writeBufferDefaultSize_(WRITE_BUFFER_DEFAULT_SIZE),
- idleReadBufferLimit_(IDLE_READ_BUFFER_LIMIT),
- idleWriteBufferLimit_(IDLE_WRITE_BUFFER_LIMIT),
- resizeBufferEveryN_(RESIZE_BUFFER_EVERY_N),
- overloaded_(false),
- nConnectionsDropped_(0),
- nTotalConnectionsDropped_(0) {}
-
- TNonblockingServer(boost::shared_ptr<TProcessor> processor,
- boost::shared_ptr<TProtocolFactory> protocolFactory,
- int port,
- boost::shared_ptr<ThreadManager> threadManager = boost::shared_ptr<ThreadManager>()) :
- TServer(processor),
- serverSocket_(-1),
- port_(port),
- threadManager_(threadManager),
- eventBase_(NULL),
- ownEventBase_(false),
- numTConnections_(0),
- numActiveProcessors_(0),
- connectionStackLimit_(CONNECTION_STACK_LIMIT),
- maxActiveProcessors_(MAX_ACTIVE_PROCESSORS),
- maxConnections_(MAX_CONNECTIONS),
- taskExpireTime_(0),
- overloadHysteresis_(0.8),
- overloadAction_(T_OVERLOAD_NO_ACTION),
- writeBufferDefaultSize_(WRITE_BUFFER_DEFAULT_SIZE),
- idleReadBufferLimit_(IDLE_READ_BUFFER_LIMIT),
- idleWriteBufferLimit_(IDLE_WRITE_BUFFER_LIMIT),
- resizeBufferEveryN_(RESIZE_BUFFER_EVERY_N),
- overloaded_(false),
- nConnectionsDropped_(0),
- nTotalConnectionsDropped_(0) {
- setInputTransportFactory(boost::shared_ptr<TTransportFactory>(new TTransportFactory()));
- setOutputTransportFactory(boost::shared_ptr<TTransportFactory>(new TTransportFactory()));
+ TServer(processor) {
+ init(port);
+ }
+
+ TNonblockingServer(
+ const boost::shared_ptr<TProcessor>& processor,
+ const boost::shared_ptr<TProtocolFactory>& protocolFactory,
+ int port,
+ const boost::shared_ptr<ThreadManager>& threadManager =
+ boost::shared_ptr<ThreadManager>()) :
+ TServer(processor) {
+
+ init(port);
+
setInputProtocolFactory(protocolFactory);
setOutputProtocolFactory(protocolFactory);
setThreadManager(threadManager);
}
- TNonblockingServer(boost::shared_ptr<TProcessor> processor,
- boost::shared_ptr<TTransportFactory> inputTransportFactory,
- boost::shared_ptr<TTransportFactory> outputTransportFactory,
- boost::shared_ptr<TProtocolFactory> inputProtocolFactory,
- boost::shared_ptr<TProtocolFactory> outputProtocolFactory,
- int port,
- boost::shared_ptr<ThreadManager> threadManager = boost::shared_ptr<ThreadManager>()) :
- TServer(processor),
- serverSocket_(-1),
- port_(port),
- threadManager_(threadManager),
- eventBase_(NULL),
- ownEventBase_(false),
- numTConnections_(0),
- numActiveProcessors_(0),
- connectionStackLimit_(CONNECTION_STACK_LIMIT),
- maxActiveProcessors_(MAX_ACTIVE_PROCESSORS),
- maxConnections_(MAX_CONNECTIONS),
- taskExpireTime_(0),
- overloadHysteresis_(0.8),
- overloadAction_(T_OVERLOAD_NO_ACTION),
- writeBufferDefaultSize_(WRITE_BUFFER_DEFAULT_SIZE),
- idleReadBufferLimit_(IDLE_READ_BUFFER_LIMIT),
- idleWriteBufferLimit_(IDLE_WRITE_BUFFER_LIMIT),
- resizeBufferEveryN_(RESIZE_BUFFER_EVERY_N),
- overloaded_(false),
- nConnectionsDropped_(0),
- nTotalConnectionsDropped_(0) {
+ TNonblockingServer(
+ const boost::shared_ptr<TProcessor>& processor,
+ const boost::shared_ptr<TTransportFactory>& inputTransportFactory,
+ const boost::shared_ptr<TTransportFactory>& outputTransportFactory,
+ const boost::shared_ptr<TProtocolFactory>& inputProtocolFactory,
+ const boost::shared_ptr<TProtocolFactory>& outputProtocolFactory,
+ int port,
+ const boost::shared_ptr<ThreadManager>& threadManager =
+ boost::shared_ptr<ThreadManager>()) :
+ TServer(processor) {
+
+ init(port);
+
setInputTransportFactory(inputTransportFactory);
setOutputTransportFactory(outputTransportFactory);
setInputProtocolFactory(inputProtocolFactory);