THRIFT-2221: detect C++11 and use std namespace for memory operations (smart_ptr)
Client: C++

This closes #1328
diff --git a/test/cpp/src/StressTestNonBlocking.cpp b/test/cpp/src/StressTestNonBlocking.cpp
index 1ebb9e0..e68988f 100644
--- a/test/cpp/src/StressTestNonBlocking.cpp
+++ b/test/cpp/src/StressTestNonBlocking.cpp
@@ -33,11 +33,10 @@
 #include <thrift/transport/TTransportUtils.h>
 #include <thrift/transport/TFileTransport.h>
 #include <thrift/TLogging.h>
+#include <thrift/stdcxx.h>
 
 #include "Service.h"
 
-#include <boost/shared_ptr.hpp>
-
 #include <iostream>
 #include <set>
 #include <stdexcept>
@@ -110,8 +109,8 @@
 
 class ClientThread : public Runnable {
 public:
-  ClientThread(boost::shared_ptr<TTransport> transport,
-               boost::shared_ptr<ServiceClient> client,
+  ClientThread(stdcxx::shared_ptr<TTransport> transport,
+               stdcxx::shared_ptr<ServiceClient> client,
                Monitor& monitor,
                size_t& workerCount,
                size_t loopCount,
@@ -222,8 +221,8 @@
     }
   }
 
-  boost::shared_ptr<TTransport> _transport;
-  boost::shared_ptr<ServiceClient> _client;
+  stdcxx::shared_ptr<TTransport> _transport;
+  stdcxx::shared_ptr<ServiceClient> _client;
   Monitor& _monitor;
   size_t& _workerCount;
   size_t _loopCount;
@@ -345,24 +344,24 @@
     cerr << usage.str();
   }
 
-  boost::shared_ptr<PlatformThreadFactory> threadFactory
-      = boost::shared_ptr<PlatformThreadFactory>(new PlatformThreadFactory());
+  stdcxx::shared_ptr<PlatformThreadFactory> threadFactory
+      = stdcxx::shared_ptr<PlatformThreadFactory>(new PlatformThreadFactory());
 
   // Dispatcher
-  boost::shared_ptr<Server> serviceHandler(new Server());
+  stdcxx::shared_ptr<Server> serviceHandler(new Server());
 
   if (replayRequests) {
-    boost::shared_ptr<Server> serviceHandler(new Server());
-    boost::shared_ptr<ServiceProcessor> serviceProcessor(new ServiceProcessor(serviceHandler));
+    stdcxx::shared_ptr<Server> serviceHandler(new Server());
+    stdcxx::shared_ptr<ServiceProcessor> serviceProcessor(new ServiceProcessor(serviceHandler));
 
     // Transports
-    boost::shared_ptr<TFileTransport> fileTransport(new TFileTransport(requestLogPath));
+    stdcxx::shared_ptr<TFileTransport> fileTransport(new TFileTransport(requestLogPath));
     fileTransport->setChunkSize(2 * 1024 * 1024);
     fileTransport->setMaxEventSize(1024 * 16);
     fileTransport->seekToEnd();
 
     // Protocol Factory
-    boost::shared_ptr<TProtocolFactory> protocolFactory(new TBinaryProtocolFactory());
+    stdcxx::shared_ptr<TProtocolFactory> protocolFactory(new TBinaryProtocolFactory());
 
     TFileProcessor fileProcessor(serviceProcessor, protocolFactory, fileTransport);
 
@@ -372,48 +371,50 @@
 
   if (runServer) {
 
-    boost::shared_ptr<ServiceProcessor> serviceProcessor(new ServiceProcessor(serviceHandler));
+    stdcxx::shared_ptr<ServiceProcessor> serviceProcessor(new ServiceProcessor(serviceHandler));
 
     // Protocol Factory
-    boost::shared_ptr<TProtocolFactory> protocolFactory(new TBinaryProtocolFactory());
+    stdcxx::shared_ptr<TProtocolFactory> protocolFactory(new TBinaryProtocolFactory());
 
     // Transport Factory
-    boost::shared_ptr<TTransportFactory> transportFactory;
+    stdcxx::shared_ptr<TTransportFactory> transportFactory;
 
     if (logRequests) {
       // initialize the log file
-      boost::shared_ptr<TFileTransport> fileTransport(new TFileTransport(requestLogPath));
+      stdcxx::shared_ptr<TFileTransport> fileTransport(new TFileTransport(requestLogPath));
       fileTransport->setChunkSize(2 * 1024 * 1024);
       fileTransport->setMaxEventSize(1024 * 16);
 
       transportFactory
-          = boost::shared_ptr<TTransportFactory>(new TPipedTransportFactory(fileTransport));
+          = stdcxx::shared_ptr<TTransportFactory>(new TPipedTransportFactory(fileTransport));
     }
 
-    boost::shared_ptr<Thread> serverThread;
-    boost::shared_ptr<Thread> serverThread2;
-    boost::shared_ptr<transport::TNonblockingServerSocket> nbSocket1, nbSocket2;
+    stdcxx::shared_ptr<Thread> serverThread;
+    stdcxx::shared_ptr<Thread> serverThread2;
+    stdcxx::shared_ptr<transport::TNonblockingServerSocket> nbSocket1;
+    stdcxx::shared_ptr<transport::TNonblockingServerSocket> nbSocket2;
 
     if (serverType == "simple") {
+
       nbSocket1.reset(new transport::TNonblockingServerSocket(port));
-      serverThread = threadFactory->newThread(boost::shared_ptr<TServer>(
+      serverThread = threadFactory->newThread(stdcxx::shared_ptr<TServer>(
           new TNonblockingServer(serviceProcessor, protocolFactory, nbSocket1)));
       nbSocket2.reset(new transport::TNonblockingServerSocket(port + 1));
-      serverThread2 = threadFactory->newThread(boost::shared_ptr<TServer>(
+      serverThread2 = threadFactory->newThread(stdcxx::shared_ptr<TServer>(
           new TNonblockingServer(serviceProcessor, protocolFactory, nbSocket2)));
 
     } else if (serverType == "thread-pool") {
 
-      boost::shared_ptr<ThreadManager> threadManager
+      stdcxx::shared_ptr<ThreadManager> threadManager
           = ThreadManager::newSimpleThreadManager(workerCount);
 
       threadManager->threadFactory(threadFactory);
       threadManager->start();
       nbSocket1.reset(new transport::TNonblockingServerSocket(port));
-      serverThread = threadFactory->newThread(boost::shared_ptr<TServer>(
+      serverThread = threadFactory->newThread(stdcxx::shared_ptr<TServer>(
           new TNonblockingServer(serviceProcessor, protocolFactory, nbSocket1, threadManager)));
       nbSocket2.reset(new transport::TNonblockingServerSocket(port + 1));
-      serverThread2 = threadFactory->newThread(boost::shared_ptr<TServer>(
+      serverThread2 = threadFactory->newThread(stdcxx::shared_ptr<TServer>(
           new TNonblockingServer(serviceProcessor, protocolFactory, nbSocket2, threadManager)));
     }
 
@@ -436,7 +437,7 @@
 
     size_t threadCount = 0;
 
-    set<boost::shared_ptr<Thread> > clientThreads;
+    set<stdcxx::shared_ptr<Thread> > clientThreads;
 
     if (callName == "echoVoid") {
       loopType = T_VOID;
@@ -454,16 +455,16 @@
 
     for (uint32_t ix = 0; ix < clientCount; ix++) {
 
-      boost::shared_ptr<TSocket> socket(new TSocket("127.0.0.1", port + (ix % 2)));
-      boost::shared_ptr<TFramedTransport> framedSocket(new TFramedTransport(socket));
-      boost::shared_ptr<TProtocol> protocol(new TBinaryProtocol(framedSocket));
-      boost::shared_ptr<ServiceClient> serviceClient(new ServiceClient(protocol));
+      stdcxx::shared_ptr<TSocket> socket(new TSocket("127.0.0.1", port + (ix % 2)));
+      stdcxx::shared_ptr<TFramedTransport> framedSocket(new TFramedTransport(socket));
+      stdcxx::shared_ptr<TProtocol> protocol(new TBinaryProtocol(framedSocket));
+      stdcxx::shared_ptr<ServiceClient> serviceClient(new ServiceClient(protocol));
 
-      clientThreads.insert(threadFactory->newThread(boost::shared_ptr<ClientThread>(
+      clientThreads.insert(threadFactory->newThread(stdcxx::shared_ptr<ClientThread>(
           new ClientThread(socket, serviceClient, monitor, threadCount, loopCount, loopType))));
     }
 
-    for (std::set<boost::shared_ptr<Thread> >::const_iterator thread = clientThreads.begin();
+    for (std::set<stdcxx::shared_ptr<Thread> >::const_iterator thread = clientThreads.begin();
          thread != clientThreads.end();
          thread++) {
       (*thread)->start();
@@ -496,12 +497,12 @@
     int64_t minTime = 9223372036854775807LL;
     int64_t maxTime = 0;
 
-    for (set<boost::shared_ptr<Thread> >::iterator ix = clientThreads.begin();
+    for (set<stdcxx::shared_ptr<Thread> >::iterator ix = clientThreads.begin();
          ix != clientThreads.end();
          ix++) {
 
-      boost::shared_ptr<ClientThread> client
-          = boost::dynamic_pointer_cast<ClientThread>((*ix)->runnable());
+      stdcxx::shared_ptr<ClientThread> client
+          = stdcxx::dynamic_pointer_cast<ClientThread>((*ix)->runnable());
 
       int64_t delta = client->_endTime - client->_startTime;