THRIFT-1917 Task expiration in TThreadPoolServer
authorRoger Meier <roger@apache.org>
Sun, 5 May 2013 22:21:04 +0000 (00:21 +0200)
committerRoger Meier <roger@apache.org>
Sun, 5 May 2013 22:21:04 +0000 (00:21 +0200)
Patch: Ivan Fastov

lib/cpp/src/thrift/server/TThreadPoolServer.cpp
lib/cpp/src/thrift/server/TThreadPoolServer.h

index d3b9714..ef1f522 100644 (file)
@@ -152,7 +152,7 @@ void TThreadPoolServer::serve() {
       // Add to threadmanager pool
       shared_ptr<TThreadPoolServer::Task> task(new TThreadPoolServer::Task(
             *this, processor, inputProtocol, outputProtocol, client));
-      threadManager_->add(task, timeout_);
+      threadManager_->add(task, timeout_, taskExpiration_);
 
     } catch (TTransportException& ttx) {
       if (inputTransport != NULL) { inputTransport->close(); }
@@ -202,4 +202,12 @@ void TThreadPoolServer::setTimeout(int64_t value) {
   timeout_ = value;
 }
 
+int64_t TThreadPoolServer::getTaskExpiration() const {
+  return taskExpiration_;
+}
+
+void TThreadPoolServer::setTaskExpiration(int64_t value) {
+  taskExpiration_ = value;
+}
+
 }}} // apache::thrift::server
index 70b19bb..8a1fc16 100644 (file)
@@ -49,7 +49,8 @@ class TThreadPoolServer : public TServer {
             protocolFactory),
     threadManager_(threadManager),
     stop_(false),
-    timeout_(0) {}
+    timeout_(0),
+    taskExpiration_(0) {}
 
   template<typename Processor>
   TThreadPoolServer(
@@ -62,7 +63,8 @@ class TThreadPoolServer : public TServer {
     TServer(processor, serverTransport, transportFactory, protocolFactory),
     threadManager_(threadManager),
     stop_(false),
-    timeout_(0) {}
+    timeout_(0),
+    taskExpiration_(0) {}
 
   template<typename ProcessorFactory>
   TThreadPoolServer(
@@ -79,7 +81,8 @@ class TThreadPoolServer : public TServer {
             inputProtocolFactory, outputProtocolFactory),
     threadManager_(threadManager),
     stop_(false),
-    timeout_(0) {}
+    timeout_(0),
+    taskExpiration_(0) {}
 
   template<typename Processor>
   TThreadPoolServer(
@@ -96,7 +99,8 @@ class TThreadPoolServer : public TServer {
             inputProtocolFactory, outputProtocolFactory),
     threadManager_(threadManager),
     stop_(false),
-    timeout_(0) {}
+    timeout_(0),
+    taskExpiration_(0) {}
 
   virtual ~TThreadPoolServer();
 
@@ -111,6 +115,10 @@ class TThreadPoolServer : public TServer {
     serverTransport_->interrupt();
   }
 
+  virtual int64_t getTaskExpiration() const;
+
+  virtual void setTaskExpiration(int64_t value);
+
  protected:
 
   boost::shared_ptr<ThreadManager> threadManager_;
@@ -119,6 +127,8 @@ class TThreadPoolServer : public TServer {
 
   volatile int64_t timeout_;
 
+  volatile int64_t taskExpiration_;
+
 };
 
 }}} // apache::thrift::server