Implement proper TThreadedServer shutdown


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665049 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/cpp/src/server/TThreadedServer.h b/lib/cpp/src/server/TThreadedServer.h
index c6306b2..4fe775a 100644
--- a/lib/cpp/src/server/TThreadedServer.h
+++ b/lib/cpp/src/server/TThreadedServer.h
@@ -9,6 +9,7 @@
 
 #include <server/TServer.h>
 #include <transport/TServerTransport.h>
+#include <concurrency/Monitor.h>
 #include <concurrency/Thread.h>
 
 #include <boost/shared_ptr.hpp>
@@ -18,6 +19,7 @@
 using facebook::thrift::TProcessor;
 using facebook::thrift::transport::TServerTransport;
 using facebook::thrift::transport::TTransportFactory;
+using facebook::thrift::concurrency::Monitor;
 using facebook::thrift::concurrency::ThreadFactory;
 
 class TThreadedServer : public TServer {
@@ -34,8 +36,17 @@
 
   virtual void serve();
 
+  void stop() {
+    stop_ = true;
+    serverTransport_->interrupt();
+  }
+
  protected:
   boost::shared_ptr<ThreadFactory> threadFactory_;
+  volatile bool stop_;
+
+  Monitor tasksMonitor_;
+  std::set<Task*> tasks_;
 
 };