diff options
author | cyy <cyyever@outlook.com> | 2019-01-05 16:35:14 +0800 |
---|---|---|
committer | James E. King III <jking@apache.org> | 2019-01-07 08:11:37 -0500 |
commit | 316723add4c368ffd144dd5beb55245832e073fa (patch) | |
tree | 4dc5c86e776e4818ba5fb102e33eb62cfeb8382f /test/cpp | |
parent | 52637b33aba090851436b2031476529423ea3281 (diff) | |
download | thrift-316723add4c368ffd144dd5beb55245832e073fa.tar.gz |
remove stdcxx namespace and use std directly
Diffstat (limited to 'test/cpp')
-rw-r--r-- | test/cpp/src/StressTest.cpp | 75 | ||||
-rw-r--r-- | test/cpp/src/StressTestNonBlocking.cpp | 71 | ||||
-rw-r--r-- | test/cpp/src/TestClient.cpp | 51 | ||||
-rw-r--r-- | test/cpp/src/TestServer.cpp | 119 |
4 files changed, 156 insertions, 160 deletions
diff --git a/test/cpp/src/StressTest.cpp b/test/cpp/src/StressTest.cpp index 5ff5e44f9..585f89a9e 100644 --- a/test/cpp/src/StressTest.cpp +++ b/test/cpp/src/StressTest.cpp @@ -31,7 +31,6 @@ #include <thrift/transport/TTransportUtils.h> #include <thrift/transport/TFileTransport.h> #include <thrift/TLogging.h> -#include <thrift/stdcxx.h> #include "Service.h" #include <iostream> @@ -108,8 +107,8 @@ enum TransportOpenCloseBehavior { }; class ClientThread : public Runnable { public: - ClientThread(stdcxx::shared_ptr<TTransport> transport, - stdcxx::shared_ptr<ServiceIf> client, + ClientThread(std::shared_ptr<TTransport> transport, + std::shared_ptr<ServiceIf> client, Monitor& monitor, size_t& workerCount, size_t loopCount, @@ -225,8 +224,8 @@ public: } } - stdcxx::shared_ptr<TTransport> _transport; - stdcxx::shared_ptr<ServiceIf> _client; + std::shared_ptr<TTransport> _transport; + std::shared_ptr<ServiceIf> _client; Monitor& _monitor; size_t& _workerCount; size_t _loopCount; @@ -391,24 +390,24 @@ int main(int argc, char** argv) { cerr << usage.str(); } - stdcxx::shared_ptr<PlatformThreadFactory> threadFactory - = stdcxx::shared_ptr<PlatformThreadFactory>(new PlatformThreadFactory()); + std::shared_ptr<PlatformThreadFactory> threadFactory + = std::shared_ptr<PlatformThreadFactory>(new PlatformThreadFactory()); // Dispatcher - stdcxx::shared_ptr<Server> serviceHandler(new Server()); + std::shared_ptr<Server> serviceHandler(new Server()); if (replayRequests) { - stdcxx::shared_ptr<Server> serviceHandler(new Server()); - stdcxx::shared_ptr<ServiceProcessor> serviceProcessor(new ServiceProcessor(serviceHandler)); + std::shared_ptr<Server> serviceHandler(new Server()); + std::shared_ptr<ServiceProcessor> serviceProcessor(new ServiceProcessor(serviceHandler)); // Transports - stdcxx::shared_ptr<TFileTransport> fileTransport(new TFileTransport(requestLogPath)); + std::shared_ptr<TFileTransport> fileTransport(new TFileTransport(requestLogPath)); fileTransport->setChunkSize(2 * 1024 * 1024); fileTransport->setMaxEventSize(1024 * 16); fileTransport->seekToEnd(); // Protocol Factory - stdcxx::shared_ptr<TProtocolFactory> protocolFactory(new TBinaryProtocolFactory()); + std::shared_ptr<TProtocolFactory> protocolFactory(new TBinaryProtocolFactory()); TFileProcessor fileProcessor(serviceProcessor, protocolFactory, fileTransport); @@ -418,28 +417,28 @@ int main(int argc, char** argv) { if (runServer) { - stdcxx::shared_ptr<ServiceProcessor> serviceProcessor(new ServiceProcessor(serviceHandler)); + std::shared_ptr<ServiceProcessor> serviceProcessor(new ServiceProcessor(serviceHandler)); // Transport - stdcxx::shared_ptr<TServerSocket> serverSocket(new TServerSocket(port)); + std::shared_ptr<TServerSocket> serverSocket(new TServerSocket(port)); // Transport Factory - stdcxx::shared_ptr<TTransportFactory> transportFactory(new TBufferedTransportFactory()); + std::shared_ptr<TTransportFactory> transportFactory(new TBufferedTransportFactory()); // Protocol Factory - stdcxx::shared_ptr<TProtocolFactory> protocolFactory(new TBinaryProtocolFactory()); + std::shared_ptr<TProtocolFactory> protocolFactory(new TBinaryProtocolFactory()); if (logRequests) { // initialize the log file - stdcxx::shared_ptr<TFileTransport> fileTransport(new TFileTransport(requestLogPath)); + std::shared_ptr<TFileTransport> fileTransport(new TFileTransport(requestLogPath)); fileTransport->setChunkSize(2 * 1024 * 1024); fileTransport->setMaxEventSize(1024 * 16); transportFactory - = stdcxx::shared_ptr<TTransportFactory>(new TPipedTransportFactory(fileTransport)); + = std::shared_ptr<TTransportFactory>(new TPipedTransportFactory(fileTransport)); } - stdcxx::shared_ptr<TServer> server; + std::shared_ptr<TServer> server; if (serverType == "simple") { @@ -453,7 +452,7 @@ int main(int argc, char** argv) { } else if (serverType == "thread-pool") { - stdcxx::shared_ptr<ThreadManager> threadManager + std::shared_ptr<ThreadManager> threadManager = ThreadManager::newSimpleThreadManager(workerCount); threadManager->threadFactory(threadFactory); @@ -465,9 +464,9 @@ int main(int argc, char** argv) { threadManager)); } - stdcxx::shared_ptr<TStartObserver> observer(new TStartObserver); + std::shared_ptr<TStartObserver> observer(new TStartObserver); server->setServerEventHandler(observer); - stdcxx::shared_ptr<Thread> serverThread = threadFactory->newThread(server); + std::shared_ptr<Thread> serverThread = threadFactory->newThread(server); cerr << "Starting the server on port " << port << endl; @@ -486,7 +485,7 @@ int main(int argc, char** argv) { size_t threadCount = 0; - set<stdcxx::shared_ptr<Thread> > clientThreads; + set<std::shared_ptr<Thread> > clientThreads; if (callName == "echoVoid") { loopType = T_VOID; @@ -505,28 +504,28 @@ int main(int argc, char** argv) { if(clientType == "regular") { for (size_t ix = 0; ix < clientCount; ix++) { - stdcxx::shared_ptr<TSocket> socket(new TSocket("127.0.0.1", port)); - stdcxx::shared_ptr<TBufferedTransport> bufferedSocket(new TBufferedTransport(socket, 2048)); - stdcxx::shared_ptr<TProtocol> protocol(new TBinaryProtocol(bufferedSocket)); - stdcxx::shared_ptr<ServiceClient> serviceClient(new ServiceClient(protocol)); + std::shared_ptr<TSocket> socket(new TSocket("127.0.0.1", port)); + std::shared_ptr<TBufferedTransport> bufferedSocket(new TBufferedTransport(socket, 2048)); + std::shared_ptr<TProtocol> protocol(new TBinaryProtocol(bufferedSocket)); + std::shared_ptr<ServiceClient> serviceClient(new ServiceClient(protocol)); - clientThreads.insert(threadFactory->newThread(stdcxx::shared_ptr<ClientThread>( + clientThreads.insert(threadFactory->newThread(std::shared_ptr<ClientThread>( new ClientThread(socket, serviceClient, monitor, threadCount, loopCount, loopType, OpenAndCloseTransportInThread)))); } } else if(clientType == "concurrent") { - stdcxx::shared_ptr<TSocket> socket(new TSocket("127.0.0.1", port)); - stdcxx::shared_ptr<TBufferedTransport> bufferedSocket(new TBufferedTransport(socket, 2048)); - stdcxx::shared_ptr<TProtocol> protocol(new TBinaryProtocol(bufferedSocket)); - //stdcxx::shared_ptr<ServiceClient> serviceClient(new ServiceClient(protocol)); - stdcxx::shared_ptr<ServiceConcurrentClient> serviceClient(new ServiceConcurrentClient(protocol)); + std::shared_ptr<TSocket> socket(new TSocket("127.0.0.1", port)); + std::shared_ptr<TBufferedTransport> bufferedSocket(new TBufferedTransport(socket, 2048)); + std::shared_ptr<TProtocol> protocol(new TBinaryProtocol(bufferedSocket)); + //std::shared_ptr<ServiceClient> serviceClient(new ServiceClient(protocol)); + std::shared_ptr<ServiceConcurrentClient> serviceClient(new ServiceConcurrentClient(protocol)); socket->open(); for (size_t ix = 0; ix < clientCount; ix++) { - clientThreads.insert(threadFactory->newThread(stdcxx::shared_ptr<ClientThread>( + clientThreads.insert(threadFactory->newThread(std::shared_ptr<ClientThread>( new ClientThread(socket, serviceClient, monitor, threadCount, loopCount, loopType, DontOpenAndCloseTransportInThread)))); } } - for (std::set<stdcxx::shared_ptr<Thread> >::const_iterator thread = clientThreads.begin(); + for (std::set<std::shared_ptr<Thread> >::const_iterator thread = clientThreads.begin(); thread != clientThreads.end(); thread++) { (*thread)->start(); @@ -559,12 +558,12 @@ int main(int argc, char** argv) { int64_t minTime = 9223372036854775807LL; int64_t maxTime = 0; - for (set<stdcxx::shared_ptr<Thread> >::iterator ix = clientThreads.begin(); + for (set<std::shared_ptr<Thread> >::iterator ix = clientThreads.begin(); ix != clientThreads.end(); ix++) { - stdcxx::shared_ptr<ClientThread> client - = stdcxx::dynamic_pointer_cast<ClientThread>((*ix)->runnable()); + std::shared_ptr<ClientThread> client + = std::dynamic_pointer_cast<ClientThread>((*ix)->runnable()); int64_t delta = client->_endTime - client->_startTime; diff --git a/test/cpp/src/StressTestNonBlocking.cpp b/test/cpp/src/StressTestNonBlocking.cpp index e68988f41..1d3ed732b 100644 --- a/test/cpp/src/StressTestNonBlocking.cpp +++ b/test/cpp/src/StressTestNonBlocking.cpp @@ -33,7 +33,6 @@ #include <thrift/transport/TTransportUtils.h> #include <thrift/transport/TFileTransport.h> #include <thrift/TLogging.h> -#include <thrift/stdcxx.h> #include "Service.h" @@ -109,8 +108,8 @@ private: class ClientThread : public Runnable { public: - ClientThread(stdcxx::shared_ptr<TTransport> transport, - stdcxx::shared_ptr<ServiceClient> client, + ClientThread(std::shared_ptr<TTransport> transport, + std::shared_ptr<ServiceClient> client, Monitor& monitor, size_t& workerCount, size_t loopCount, @@ -221,8 +220,8 @@ public: } } - stdcxx::shared_ptr<TTransport> _transport; - stdcxx::shared_ptr<ServiceClient> _client; + std::shared_ptr<TTransport> _transport; + std::shared_ptr<ServiceClient> _client; Monitor& _monitor; size_t& _workerCount; size_t _loopCount; @@ -344,24 +343,24 @@ int main(int argc, char** argv) { cerr << usage.str(); } - stdcxx::shared_ptr<PlatformThreadFactory> threadFactory - = stdcxx::shared_ptr<PlatformThreadFactory>(new PlatformThreadFactory()); + std::shared_ptr<PlatformThreadFactory> threadFactory + = std::shared_ptr<PlatformThreadFactory>(new PlatformThreadFactory()); // Dispatcher - stdcxx::shared_ptr<Server> serviceHandler(new Server()); + std::shared_ptr<Server> serviceHandler(new Server()); if (replayRequests) { - stdcxx::shared_ptr<Server> serviceHandler(new Server()); - stdcxx::shared_ptr<ServiceProcessor> serviceProcessor(new ServiceProcessor(serviceHandler)); + std::shared_ptr<Server> serviceHandler(new Server()); + std::shared_ptr<ServiceProcessor> serviceProcessor(new ServiceProcessor(serviceHandler)); // Transports - stdcxx::shared_ptr<TFileTransport> fileTransport(new TFileTransport(requestLogPath)); + std::shared_ptr<TFileTransport> fileTransport(new TFileTransport(requestLogPath)); fileTransport->setChunkSize(2 * 1024 * 1024); fileTransport->setMaxEventSize(1024 * 16); fileTransport->seekToEnd(); // Protocol Factory - stdcxx::shared_ptr<TProtocolFactory> protocolFactory(new TBinaryProtocolFactory()); + std::shared_ptr<TProtocolFactory> protocolFactory(new TBinaryProtocolFactory()); TFileProcessor fileProcessor(serviceProcessor, protocolFactory, fileTransport); @@ -371,50 +370,50 @@ int main(int argc, char** argv) { if (runServer) { - stdcxx::shared_ptr<ServiceProcessor> serviceProcessor(new ServiceProcessor(serviceHandler)); + std::shared_ptr<ServiceProcessor> serviceProcessor(new ServiceProcessor(serviceHandler)); // Protocol Factory - stdcxx::shared_ptr<TProtocolFactory> protocolFactory(new TBinaryProtocolFactory()); + std::shared_ptr<TProtocolFactory> protocolFactory(new TBinaryProtocolFactory()); // Transport Factory - stdcxx::shared_ptr<TTransportFactory> transportFactory; + std::shared_ptr<TTransportFactory> transportFactory; if (logRequests) { // initialize the log file - stdcxx::shared_ptr<TFileTransport> fileTransport(new TFileTransport(requestLogPath)); + std::shared_ptr<TFileTransport> fileTransport(new TFileTransport(requestLogPath)); fileTransport->setChunkSize(2 * 1024 * 1024); fileTransport->setMaxEventSize(1024 * 16); transportFactory - = stdcxx::shared_ptr<TTransportFactory>(new TPipedTransportFactory(fileTransport)); + = std::shared_ptr<TTransportFactory>(new TPipedTransportFactory(fileTransport)); } - stdcxx::shared_ptr<Thread> serverThread; - stdcxx::shared_ptr<Thread> serverThread2; - stdcxx::shared_ptr<transport::TNonblockingServerSocket> nbSocket1; - stdcxx::shared_ptr<transport::TNonblockingServerSocket> nbSocket2; + std::shared_ptr<Thread> serverThread; + std::shared_ptr<Thread> serverThread2; + std::shared_ptr<transport::TNonblockingServerSocket> nbSocket1; + std::shared_ptr<transport::TNonblockingServerSocket> nbSocket2; if (serverType == "simple") { nbSocket1.reset(new transport::TNonblockingServerSocket(port)); - serverThread = threadFactory->newThread(stdcxx::shared_ptr<TServer>( + serverThread = threadFactory->newThread(std::shared_ptr<TServer>( new TNonblockingServer(serviceProcessor, protocolFactory, nbSocket1))); nbSocket2.reset(new transport::TNonblockingServerSocket(port + 1)); - serverThread2 = threadFactory->newThread(stdcxx::shared_ptr<TServer>( + serverThread2 = threadFactory->newThread(std::shared_ptr<TServer>( new TNonblockingServer(serviceProcessor, protocolFactory, nbSocket2))); } else if (serverType == "thread-pool") { - stdcxx::shared_ptr<ThreadManager> threadManager + std::shared_ptr<ThreadManager> threadManager = ThreadManager::newSimpleThreadManager(workerCount); threadManager->threadFactory(threadFactory); threadManager->start(); nbSocket1.reset(new transport::TNonblockingServerSocket(port)); - serverThread = threadFactory->newThread(stdcxx::shared_ptr<TServer>( + serverThread = threadFactory->newThread(std::shared_ptr<TServer>( new TNonblockingServer(serviceProcessor, protocolFactory, nbSocket1, threadManager))); nbSocket2.reset(new transport::TNonblockingServerSocket(port + 1)); - serverThread2 = threadFactory->newThread(stdcxx::shared_ptr<TServer>( + serverThread2 = threadFactory->newThread(std::shared_ptr<TServer>( new TNonblockingServer(serviceProcessor, protocolFactory, nbSocket2, threadManager))); } @@ -437,7 +436,7 @@ int main(int argc, char** argv) { size_t threadCount = 0; - set<stdcxx::shared_ptr<Thread> > clientThreads; + set<std::shared_ptr<Thread> > clientThreads; if (callName == "echoVoid") { loopType = T_VOID; @@ -455,16 +454,16 @@ int main(int argc, char** argv) { for (uint32_t ix = 0; ix < clientCount; ix++) { - 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)); + std::shared_ptr<TSocket> socket(new TSocket("127.0.0.1", port + (ix % 2))); + std::shared_ptr<TFramedTransport> framedSocket(new TFramedTransport(socket)); + std::shared_ptr<TProtocol> protocol(new TBinaryProtocol(framedSocket)); + std::shared_ptr<ServiceClient> serviceClient(new ServiceClient(protocol)); - clientThreads.insert(threadFactory->newThread(stdcxx::shared_ptr<ClientThread>( + clientThreads.insert(threadFactory->newThread(std::shared_ptr<ClientThread>( new ClientThread(socket, serviceClient, monitor, threadCount, loopCount, loopType)))); } - for (std::set<stdcxx::shared_ptr<Thread> >::const_iterator thread = clientThreads.begin(); + for (std::set<std::shared_ptr<Thread> >::const_iterator thread = clientThreads.begin(); thread != clientThreads.end(); thread++) { (*thread)->start(); @@ -497,12 +496,12 @@ int main(int argc, char** argv) { int64_t minTime = 9223372036854775807LL; int64_t maxTime = 0; - for (set<stdcxx::shared_ptr<Thread> >::iterator ix = clientThreads.begin(); + for (set<std::shared_ptr<Thread> >::iterator ix = clientThreads.begin(); ix != clientThreads.end(); ix++) { - stdcxx::shared_ptr<ClientThread> client - = stdcxx::dynamic_pointer_cast<ClientThread>((*ix)->runnable()); + std::shared_ptr<ClientThread> client + = std::dynamic_pointer_cast<ClientThread>((*ix)->runnable()); int64_t delta = client->_endTime - client->_startTime; diff --git a/test/cpp/src/TestClient.cpp b/test/cpp/src/TestClient.cpp index ca213260e..89f3fd13c 100644 --- a/test/cpp/src/TestClient.cpp +++ b/test/cpp/src/TestClient.cpp @@ -46,7 +46,6 @@ #include <boost/filesystem.hpp> #include <boost/program_options.hpp> #include <boost/random/random_device.hpp> -#include <thrift/stdcxx.h> #if _WIN32 #include <thrift/windows/TWinsockSingleton.h> #endif @@ -98,10 +97,10 @@ static void testVoid_clientReturn(event_base* base, ThriftTestCobClient* client) for (int testNr = 0; testNr < 10; ++testNr) { std::ostringstream os; os << "test" << testNr; - client->testString(stdcxx::bind(testString_clientReturn, + client->testString(std::bind(testString_clientReturn, base, testNr, - stdcxx::placeholders::_1), + std::placeholders::_1), os.str()); } } catch (TException& exn) { @@ -254,18 +253,18 @@ int main(int argc, char** argv) { } // THRIFT-4164: The factory MUST outlive any sockets it creates for correct behavior! - stdcxx::shared_ptr<TSSLSocketFactory> factory; - stdcxx::shared_ptr<TSocket> socket; - stdcxx::shared_ptr<TTransport> transport; - stdcxx::shared_ptr<TProtocol> protocol; - stdcxx::shared_ptr<TProtocol> protocol2; // SecondService for multiplexed + std::shared_ptr<TSSLSocketFactory> factory; + std::shared_ptr<TSocket> socket; + std::shared_ptr<TTransport> transport; + std::shared_ptr<TProtocol> protocol; + std::shared_ptr<TProtocol> protocol2; // SecondService for multiplexed if (ssl) { cout << "Client Certificate File: " << certPath << endl; cout << "Client Key File: " << keyPath << endl; cout << "CA File: " << caPath << endl; - factory = stdcxx::shared_ptr<TSSLSocketFactory>(new TSSLSocketFactory()); + factory = std::shared_ptr<TSSLSocketFactory>(new TSSLSocketFactory()); factory->ciphers("ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH"); factory->loadTrustedCertificates(caPath.c_str()); factory->loadCertificate(certPath.c_str()); @@ -277,42 +276,42 @@ int main(int argc, char** argv) { if (abstract_namespace) { std::string abstract_socket("\0", 1); abstract_socket += domain_socket; - socket = stdcxx::shared_ptr<TSocket>(new TSocket(abstract_socket)); + socket = std::shared_ptr<TSocket>(new TSocket(abstract_socket)); } else { - socket = stdcxx::shared_ptr<TSocket>(new TSocket(domain_socket)); + socket = std::shared_ptr<TSocket>(new TSocket(domain_socket)); } port = 0; } else { - socket = stdcxx::shared_ptr<TSocket>(new TSocket(host, port)); + socket = std::shared_ptr<TSocket>(new TSocket(host, port)); } } if (transport_type.compare("http") == 0) { - transport = stdcxx::make_shared<THttpClient>(socket, host, "/service"); + transport = std::make_shared<THttpClient>(socket, host, "/service"); } else if (transport_type.compare("framed") == 0) { - transport = stdcxx::make_shared<TFramedTransport>(socket); + transport = std::make_shared<TFramedTransport>(socket); } else { - transport = stdcxx::make_shared<TBufferedTransport>(socket); + transport = std::make_shared<TBufferedTransport>(socket); } if (zlib) { - transport = stdcxx::make_shared<TZlibTransport>(transport); + transport = std::make_shared<TZlibTransport>(transport); } if (protocol_type == "json" || protocol_type == "multij") { - protocol = stdcxx::make_shared<TJSONProtocol>(transport); + protocol = std::make_shared<TJSONProtocol>(transport); } else if (protocol_type == "compact" || protocol_type == "multic") { - protocol = stdcxx::make_shared<TCompactProtocol>(transport); + protocol = std::make_shared<TCompactProtocol>(transport); } else if (protocol_type == "header" || protocol_type == "multih") { - protocol = stdcxx::make_shared<THeaderProtocol>(transport); + protocol = std::make_shared<THeaderProtocol>(transport); } else { - protocol = stdcxx::make_shared<TBinaryProtocol>(transport); + protocol = std::make_shared<TBinaryProtocol>(transport); } if (boost::starts_with(protocol_type, "multi")) { - protocol2 = stdcxx::make_shared<TMultiplexedProtocol>(protocol, "SecondService"); + protocol2 = std::make_shared<TMultiplexedProtocol>(protocol, "SecondService"); // we don't need access to the original protocol any more, so... - protocol = stdcxx::make_shared<TMultiplexedProtocol>(protocol, "ThriftTest"); + protocol = std::make_shared<TMultiplexedProtocol>(protocol, "ThriftTest"); } // Connection info @@ -334,14 +333,14 @@ int main(int argc, char** argv) { cout << "Libevent Features: 0x" << hex << event_base_get_features(base) << endl; #endif - stdcxx::shared_ptr<TProtocolFactory> protocolFactory(new TBinaryProtocolFactory()); + std::shared_ptr<TProtocolFactory> protocolFactory(new TBinaryProtocolFactory()); - stdcxx::shared_ptr<TAsyncChannel> channel( + std::shared_ptr<TAsyncChannel> channel( new TEvhttpClientChannel(host.c_str(), "/", host.c_str(), port, base)); ThriftTestCobClient* client = new ThriftTestCobClient(channel, protocolFactory.get()); - client->testVoid(stdcxx::bind(testVoid_clientReturn, + client->testVoid(std::bind(testVoid_clientReturn, base, - stdcxx::placeholders::_1)); + std::placeholders::_1)); event_base_loop(base, 0); return 0; diff --git a/test/cpp/src/TestServer.cpp b/test/cpp/src/TestServer.cpp index 323f87354..622201766 100644 --- a/test/cpp/src/TestServer.cpp +++ b/test/cpp/src/TestServer.cpp @@ -61,7 +61,6 @@ #include <boost/algorithm/string.hpp> #include <boost/program_options.hpp> #include <boost/filesystem.hpp> -#include <thrift/stdcxx.h> #if _WIN32 #include <thrift/windows/TWinsockSingleton.h> @@ -395,66 +394,66 @@ class TestProcessorEventHandler : public TProcessorEventHandler { class TestHandlerAsync : public ThriftTestCobSvIf { public: - TestHandlerAsync(stdcxx::shared_ptr<TestHandler>& handler) : _delegate(handler) {} + TestHandlerAsync(std::shared_ptr<TestHandler>& handler) : _delegate(handler) {} virtual ~TestHandlerAsync() {} - virtual void testVoid(stdcxx::function<void()> cob) { + virtual void testVoid(std::function<void()> cob) { _delegate->testVoid(); cob(); } - virtual void testString(stdcxx::function<void(std::string const& _return)> cob, + virtual void testString(std::function<void(std::string const& _return)> cob, const std::string& thing) { std::string res; _delegate->testString(res, thing); cob(res); } - virtual void testBool(stdcxx::function<void(bool const& _return)> cob, const bool thing) { + virtual void testBool(std::function<void(bool const& _return)> cob, const bool thing) { bool res = _delegate->testBool(thing); cob(res); } - virtual void testByte(stdcxx::function<void(int8_t const& _return)> cob, const int8_t thing) { + virtual void testByte(std::function<void(int8_t const& _return)> cob, const int8_t thing) { int8_t res = _delegate->testByte(thing); cob(res); } - virtual void testI32(stdcxx::function<void(int32_t const& _return)> cob, const int32_t thing) { + virtual void testI32(std::function<void(int32_t const& _return)> cob, const int32_t thing) { int32_t res = _delegate->testI32(thing); cob(res); } - virtual void testI64(stdcxx::function<void(int64_t const& _return)> cob, const int64_t thing) { + virtual void testI64(std::function<void(int64_t const& _return)> cob, const int64_t thing) { int64_t res = _delegate->testI64(thing); cob(res); } - virtual void testDouble(stdcxx::function<void(double const& _return)> cob, const double thing) { + virtual void testDouble(std::function<void(double const& _return)> cob, const double thing) { double res = _delegate->testDouble(thing); cob(res); } - virtual void testBinary(stdcxx::function<void(std::string const& _return)> cob, + virtual void testBinary(std::function<void(std::string const& _return)> cob, const std::string& thing) { std::string res; _delegate->testBinary(res, thing); cob(res); } - virtual void testStruct(stdcxx::function<void(Xtruct const& _return)> cob, const Xtruct& thing) { + virtual void testStruct(std::function<void(Xtruct const& _return)> cob, const Xtruct& thing) { Xtruct res; _delegate->testStruct(res, thing); cob(res); } - virtual void testNest(stdcxx::function<void(Xtruct2 const& _return)> cob, const Xtruct2& thing) { + virtual void testNest(std::function<void(Xtruct2 const& _return)> cob, const Xtruct2& thing) { Xtruct2 res; _delegate->testNest(res, thing); cob(res); } - virtual void testMap(stdcxx::function<void(std::map<int32_t, int32_t> const& _return)> cob, + virtual void testMap(std::function<void(std::map<int32_t, int32_t> const& _return)> cob, const std::map<int32_t, int32_t>& thing) { std::map<int32_t, int32_t> res; _delegate->testMap(res, thing); @@ -462,40 +461,40 @@ public: } virtual void testStringMap( - stdcxx::function<void(std::map<std::string, std::string> const& _return)> cob, + std::function<void(std::map<std::string, std::string> const& _return)> cob, const std::map<std::string, std::string>& thing) { std::map<std::string, std::string> res; _delegate->testStringMap(res, thing); cob(res); } - virtual void testSet(stdcxx::function<void(std::set<int32_t> const& _return)> cob, + virtual void testSet(std::function<void(std::set<int32_t> const& _return)> cob, const std::set<int32_t>& thing) { std::set<int32_t> res; _delegate->testSet(res, thing); cob(res); } - virtual void testList(stdcxx::function<void(std::vector<int32_t> const& _return)> cob, + virtual void testList(std::function<void(std::vector<int32_t> const& _return)> cob, const std::vector<int32_t>& thing) { std::vector<int32_t> res; _delegate->testList(res, thing); cob(res); } - virtual void testEnum(stdcxx::function<void(Numberz::type const& _return)> cob, + virtual void testEnum(std::function<void(Numberz::type const& _return)> cob, const Numberz::type thing) { Numberz::type res = _delegate->testEnum(thing); cob(res); } - virtual void testTypedef(stdcxx::function<void(UserId const& _return)> cob, const UserId thing) { + virtual void testTypedef(std::function<void(UserId const& _return)> cob, const UserId thing) { UserId res = _delegate->testTypedef(thing); cob(res); } virtual void testMapMap( - stdcxx::function<void(std::map<int32_t, std::map<int32_t, int32_t> > const& _return)> cob, + std::function<void(std::map<int32_t, std::map<int32_t, int32_t> > const& _return)> cob, const int32_t hello) { std::map<int32_t, std::map<int32_t, int32_t> > res; _delegate->testMapMap(res, hello); @@ -503,14 +502,14 @@ public: } virtual void testInsanity( - stdcxx::function<void(std::map<UserId, std::map<Numberz::type, Insanity> > const& _return)> cob, + std::function<void(std::map<UserId, std::map<Numberz::type, Insanity> > const& _return)> cob, const Insanity& argument) { std::map<UserId, std::map<Numberz::type, Insanity> > res; _delegate->testInsanity(res, argument); cob(res); } - virtual void testMulti(stdcxx::function<void(Xtruct const& _return)> cob, + virtual void testMulti(std::function<void(Xtruct const& _return)> cob, const int8_t arg0, const int32_t arg1, const int64_t arg2, @@ -523,8 +522,8 @@ public: } virtual void testException( - stdcxx::function<void()> cob, - stdcxx::function<void(::apache::thrift::TDelayedException* _throw)> exn_cob, + std::function<void()> cob, + std::function<void(::apache::thrift::TDelayedException* _throw)> exn_cob, const std::string& arg) { try { _delegate->testException(arg); @@ -536,8 +535,8 @@ public: } virtual void testMultiException( - stdcxx::function<void(Xtruct const& _return)> cob, - stdcxx::function<void(::apache::thrift::TDelayedException* _throw)> exn_cob, + std::function<void(Xtruct const& _return)> cob, + std::function<void(::apache::thrift::TDelayedException* _throw)> exn_cob, const std::string& arg0, const std::string& arg1) { Xtruct res; @@ -550,13 +549,13 @@ public: cob(res); } - virtual void testOneway(stdcxx::function<void()> cob, const int32_t secondsToSleep) { + virtual void testOneway(std::function<void()> cob, const int32_t secondsToSleep) { _delegate->testOneway(secondsToSleep); cob(); } protected: - stdcxx::shared_ptr<TestHandler> _delegate; + std::shared_ptr<TestHandler> _delegate; }; namespace po = boost::program_options; @@ -668,9 +667,9 @@ int main(int argc, char** argv) { } // Dispatcher - stdcxx::shared_ptr<TProtocolFactory> protocolFactory; + std::shared_ptr<TProtocolFactory> protocolFactory; if (protocol_type == "json" || protocol_type == "multij") { - stdcxx::shared_ptr<TProtocolFactory> jsonProtocolFactory(new TJSONProtocolFactory()); + std::shared_ptr<TProtocolFactory> jsonProtocolFactory(new TJSONProtocolFactory()); protocolFactory = jsonProtocolFactory; } else if (protocol_type == "compact" || protocol_type == "multic") { TCompactProtocolFactoryT<TBufferBase> *compactProtocolFactory = new TCompactProtocolFactoryT<TBufferBase>(); @@ -678,7 +677,7 @@ int main(int argc, char** argv) { compactProtocolFactory->setStringSizeLimit(string_limit); protocolFactory.reset(compactProtocolFactory); } else if (protocol_type == "header" || protocol_type == "multih") { - stdcxx::shared_ptr<TProtocolFactory> headerProtocolFactory(new THeaderProtocolFactory()); + std::shared_ptr<TProtocolFactory> headerProtocolFactory(new THeaderProtocolFactory()); protocolFactory = headerProtocolFactory; } else { TBinaryProtocolFactoryT<TBufferBase>* binaryProtocolFactory = new TBinaryProtocolFactoryT<TBufferBase>(); @@ -688,56 +687,56 @@ int main(int argc, char** argv) { } // Processors - stdcxx::shared_ptr<TestHandler> testHandler(new TestHandler()); - stdcxx::shared_ptr<TProcessor> testProcessor(new ThriftTestProcessor(testHandler)); + std::shared_ptr<TestHandler> testHandler(new TestHandler()); + std::shared_ptr<TProcessor> testProcessor(new ThriftTestProcessor(testHandler)); if (vm.count("processor-events")) { testProcessor->setEventHandler( - stdcxx::shared_ptr<TProcessorEventHandler>(new TestProcessorEventHandler())); + std::shared_ptr<TProcessorEventHandler>(new TestProcessorEventHandler())); } // Transport - stdcxx::shared_ptr<TSSLSocketFactory> sslSocketFactory; - stdcxx::shared_ptr<TServerSocket> serverSocket; + std::shared_ptr<TSSLSocketFactory> sslSocketFactory; + std::shared_ptr<TServerSocket> serverSocket; if (ssl) { - sslSocketFactory = stdcxx::shared_ptr<TSSLSocketFactory>(new TSSLSocketFactory()); + sslSocketFactory = std::shared_ptr<TSSLSocketFactory>(new TSSLSocketFactory()); sslSocketFactory->loadCertificate(certPath.c_str()); sslSocketFactory->loadPrivateKey(keyPath.c_str()); sslSocketFactory->ciphers("ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH"); if (server_type != "nonblocking") { - serverSocket = stdcxx::shared_ptr<TServerSocket>(new TSSLServerSocket(port, sslSocketFactory)); + serverSocket = std::shared_ptr<TServerSocket>(new TSSLServerSocket(port, sslSocketFactory)); } } else { if (domain_socket != "") { if (abstract_namespace) { std::string abstract_socket("\0", 1); abstract_socket += domain_socket; - serverSocket = stdcxx::shared_ptr<TServerSocket>(new TServerSocket(abstract_socket)); + serverSocket = std::shared_ptr<TServerSocket>(new TServerSocket(abstract_socket)); } else { unlink(domain_socket.c_str()); - serverSocket = stdcxx::shared_ptr<TServerSocket>(new TServerSocket(domain_socket)); + serverSocket = std::shared_ptr<TServerSocket>(new TServerSocket(domain_socket)); } port = 0; } else { - serverSocket = stdcxx::shared_ptr<TServerSocket>(new TServerSocket(port)); + serverSocket = std::shared_ptr<TServerSocket>(new TServerSocket(port)); } } // Factory - stdcxx::shared_ptr<TTransportFactory> transportFactory; + std::shared_ptr<TTransportFactory> transportFactory; if (transport_type == "http" && server_type != "nonblocking") { - transportFactory = stdcxx::make_shared<THttpServerTransportFactory>(); + transportFactory = std::make_shared<THttpServerTransportFactory>(); } else if (transport_type == "framed") { - transportFactory = stdcxx::make_shared<TFramedTransportFactory>(); + transportFactory = std::make_shared<TFramedTransportFactory>(); } else { - transportFactory = stdcxx::make_shared<TBufferedTransportFactory>(); + transportFactory = std::make_shared<TBufferedTransportFactory>(); } if (zlib) { // hmm.. doesn't seem to be a way to make it wrap the others... - transportFactory = stdcxx::make_shared<TZlibTransportFactory>(); + transportFactory = std::make_shared<TZlibTransportFactory>(); } // Server Info @@ -754,27 +753,27 @@ int main(int argc, char** argv) { // Multiplexed Processor if needed if (boost::starts_with(protocol_type, "multi")) { - stdcxx::shared_ptr<SecondHandler> secondHandler(new SecondHandler()); - stdcxx::shared_ptr<SecondServiceProcessor> secondProcessor(new SecondServiceProcessor(secondHandler)); + std::shared_ptr<SecondHandler> secondHandler(new SecondHandler()); + std::shared_ptr<SecondServiceProcessor> secondProcessor(new SecondServiceProcessor(secondHandler)); - stdcxx::shared_ptr<TMultiplexedProcessor> multiplexedProcessor(new TMultiplexedProcessor()); + std::shared_ptr<TMultiplexedProcessor> multiplexedProcessor(new TMultiplexedProcessor()); multiplexedProcessor->registerDefault(testProcessor); // non-multi clients go to the default processor (multi:binary, multic:compact, ...) multiplexedProcessor->registerProcessor("ThriftTest", testProcessor); multiplexedProcessor->registerProcessor("SecondService", secondProcessor); - testProcessor = stdcxx::dynamic_pointer_cast<TProcessor>(multiplexedProcessor); + testProcessor = std::dynamic_pointer_cast<TProcessor>(multiplexedProcessor); } // Server - stdcxx::shared_ptr<apache::thrift::server::TServer> server; + std::shared_ptr<apache::thrift::server::TServer> server; if (server_type == "simple") { server.reset(new TSimpleServer(testProcessor, serverSocket, transportFactory, protocolFactory)); } else if (server_type == "thread-pool") { - stdcxx::shared_ptr<PlatformThreadFactory> threadFactory - = stdcxx::shared_ptr<PlatformThreadFactory>(new PlatformThreadFactory()); + std::shared_ptr<PlatformThreadFactory> threadFactory + = std::shared_ptr<PlatformThreadFactory>(new PlatformThreadFactory()); - stdcxx::shared_ptr<ThreadManager> threadManager = ThreadManager::newSimpleThreadManager(workers); + std::shared_ptr<ThreadManager> threadManager = ThreadManager::newSimpleThreadManager(workers); threadManager->threadFactory(threadFactory); threadManager->start(); @@ -788,10 +787,10 @@ int main(int argc, char** argv) { new TThreadedServer(testProcessor, serverSocket, transportFactory, protocolFactory)); } else if (server_type == "nonblocking") { if (transport_type == "http") { - stdcxx::shared_ptr<TestHandlerAsync> testHandlerAsync(new TestHandlerAsync(testHandler)); - stdcxx::shared_ptr<TAsyncProcessor> testProcessorAsync( + std::shared_ptr<TestHandlerAsync> testHandlerAsync(new TestHandlerAsync(testHandler)); + std::shared_ptr<TAsyncProcessor> testProcessorAsync( new ThriftTestAsyncProcessor(testHandlerAsync)); - stdcxx::shared_ptr<TAsyncBufferProcessor> testBufferProcessor( + std::shared_ptr<TAsyncBufferProcessor> testBufferProcessor( new TAsyncProtocolProcessor(testProcessorAsync, protocolFactory)); // not loading nonblockingServer into "server" because @@ -800,7 +799,7 @@ int main(int argc, char** argv) { TEvhttpServer nonblockingServer(testBufferProcessor, port); nonblockingServer.serve(); } else if (transport_type == "framed") { - stdcxx::shared_ptr<transport::TNonblockingServerTransport> nbSocket; + std::shared_ptr<transport::TNonblockingServerTransport> nbSocket; nbSocket.reset( ssl ? new transport::TNonblockingSSLServerSocket(port, sslSocketFactory) : new transport::TNonblockingServerSocket(port)); @@ -815,13 +814,13 @@ int main(int argc, char** argv) { if (protocol_type == "header") { // Tell the server to use the same protocol for input / output // if using header - server->setOutputProtocolFactory(stdcxx::shared_ptr<TProtocolFactory>()); + server->setOutputProtocolFactory(std::shared_ptr<TProtocolFactory>()); } apache::thrift::concurrency::PlatformThreadFactory factory; factory.setDetached(false); - stdcxx::shared_ptr<apache::thrift::concurrency::Runnable> serverThreadRunner(server); - stdcxx::shared_ptr<apache::thrift::concurrency::Thread> thread + std::shared_ptr<apache::thrift::concurrency::Runnable> serverThreadRunner(server); + std::shared_ptr<apache::thrift::concurrency::Thread> thread = factory.newThread(serverThreadRunner); #ifdef HAVE_SIGNAL_H |