From 316723add4c368ffd144dd5beb55245832e073fa Mon Sep 17 00:00:00 2001 From: cyy Date: Sat, 5 Jan 2019 16:35:14 +0800 Subject: remove stdcxx namespace and use std directly --- test/cpp/src/StressTest.cpp | 75 ++++++++++----------- test/cpp/src/StressTestNonBlocking.cpp | 71 ++++++++++---------- test/cpp/src/TestClient.cpp | 51 +++++++------- test/cpp/src/TestServer.cpp | 119 ++++++++++++++++----------------- 4 files changed, 156 insertions(+), 160 deletions(-) (limited to 'test/cpp') 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 #include #include -#include #include "Service.h" #include @@ -108,8 +107,8 @@ enum TransportOpenCloseBehavior { }; class ClientThread : public Runnable { public: - ClientThread(stdcxx::shared_ptr transport, - stdcxx::shared_ptr client, + ClientThread(std::shared_ptr transport, + std::shared_ptr client, Monitor& monitor, size_t& workerCount, size_t loopCount, @@ -225,8 +224,8 @@ public: } } - stdcxx::shared_ptr _transport; - stdcxx::shared_ptr _client; + std::shared_ptr _transport; + std::shared_ptr _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 threadFactory - = stdcxx::shared_ptr(new PlatformThreadFactory()); + std::shared_ptr threadFactory + = std::shared_ptr(new PlatformThreadFactory()); // Dispatcher - stdcxx::shared_ptr serviceHandler(new Server()); + std::shared_ptr serviceHandler(new Server()); if (replayRequests) { - stdcxx::shared_ptr serviceHandler(new Server()); - stdcxx::shared_ptr serviceProcessor(new ServiceProcessor(serviceHandler)); + std::shared_ptr serviceHandler(new Server()); + std::shared_ptr serviceProcessor(new ServiceProcessor(serviceHandler)); // Transports - stdcxx::shared_ptr fileTransport(new TFileTransport(requestLogPath)); + std::shared_ptr fileTransport(new TFileTransport(requestLogPath)); fileTransport->setChunkSize(2 * 1024 * 1024); fileTransport->setMaxEventSize(1024 * 16); fileTransport->seekToEnd(); // Protocol Factory - stdcxx::shared_ptr protocolFactory(new TBinaryProtocolFactory()); + std::shared_ptr protocolFactory(new TBinaryProtocolFactory()); TFileProcessor fileProcessor(serviceProcessor, protocolFactory, fileTransport); @@ -418,28 +417,28 @@ int main(int argc, char** argv) { if (runServer) { - stdcxx::shared_ptr serviceProcessor(new ServiceProcessor(serviceHandler)); + std::shared_ptr serviceProcessor(new ServiceProcessor(serviceHandler)); // Transport - stdcxx::shared_ptr serverSocket(new TServerSocket(port)); + std::shared_ptr serverSocket(new TServerSocket(port)); // Transport Factory - stdcxx::shared_ptr transportFactory(new TBufferedTransportFactory()); + std::shared_ptr transportFactory(new TBufferedTransportFactory()); // Protocol Factory - stdcxx::shared_ptr protocolFactory(new TBinaryProtocolFactory()); + std::shared_ptr protocolFactory(new TBinaryProtocolFactory()); if (logRequests) { // initialize the log file - stdcxx::shared_ptr fileTransport(new TFileTransport(requestLogPath)); + std::shared_ptr fileTransport(new TFileTransport(requestLogPath)); fileTransport->setChunkSize(2 * 1024 * 1024); fileTransport->setMaxEventSize(1024 * 16); transportFactory - = stdcxx::shared_ptr(new TPipedTransportFactory(fileTransport)); + = std::shared_ptr(new TPipedTransportFactory(fileTransport)); } - stdcxx::shared_ptr server; + std::shared_ptr server; if (serverType == "simple") { @@ -453,7 +452,7 @@ int main(int argc, char** argv) { } else if (serverType == "thread-pool") { - stdcxx::shared_ptr threadManager + std::shared_ptr threadManager = ThreadManager::newSimpleThreadManager(workerCount); threadManager->threadFactory(threadFactory); @@ -465,9 +464,9 @@ int main(int argc, char** argv) { threadManager)); } - stdcxx::shared_ptr observer(new TStartObserver); + std::shared_ptr observer(new TStartObserver); server->setServerEventHandler(observer); - stdcxx::shared_ptr serverThread = threadFactory->newThread(server); + std::shared_ptr 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 > clientThreads; + set > 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 socket(new TSocket("127.0.0.1", port)); - stdcxx::shared_ptr bufferedSocket(new TBufferedTransport(socket, 2048)); - stdcxx::shared_ptr protocol(new TBinaryProtocol(bufferedSocket)); - stdcxx::shared_ptr serviceClient(new ServiceClient(protocol)); + std::shared_ptr socket(new TSocket("127.0.0.1", port)); + std::shared_ptr bufferedSocket(new TBufferedTransport(socket, 2048)); + std::shared_ptr protocol(new TBinaryProtocol(bufferedSocket)); + std::shared_ptr serviceClient(new ServiceClient(protocol)); - clientThreads.insert(threadFactory->newThread(stdcxx::shared_ptr( + clientThreads.insert(threadFactory->newThread(std::shared_ptr( new ClientThread(socket, serviceClient, monitor, threadCount, loopCount, loopType, OpenAndCloseTransportInThread)))); } } else if(clientType == "concurrent") { - stdcxx::shared_ptr socket(new TSocket("127.0.0.1", port)); - stdcxx::shared_ptr bufferedSocket(new TBufferedTransport(socket, 2048)); - stdcxx::shared_ptr protocol(new TBinaryProtocol(bufferedSocket)); - //stdcxx::shared_ptr serviceClient(new ServiceClient(protocol)); - stdcxx::shared_ptr serviceClient(new ServiceConcurrentClient(protocol)); + std::shared_ptr socket(new TSocket("127.0.0.1", port)); + std::shared_ptr bufferedSocket(new TBufferedTransport(socket, 2048)); + std::shared_ptr protocol(new TBinaryProtocol(bufferedSocket)); + //std::shared_ptr serviceClient(new ServiceClient(protocol)); + std::shared_ptr serviceClient(new ServiceConcurrentClient(protocol)); socket->open(); for (size_t ix = 0; ix < clientCount; ix++) { - clientThreads.insert(threadFactory->newThread(stdcxx::shared_ptr( + clientThreads.insert(threadFactory->newThread(std::shared_ptr( new ClientThread(socket, serviceClient, monitor, threadCount, loopCount, loopType, DontOpenAndCloseTransportInThread)))); } } - for (std::set >::const_iterator thread = clientThreads.begin(); + for (std::set >::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 >::iterator ix = clientThreads.begin(); + for (set >::iterator ix = clientThreads.begin(); ix != clientThreads.end(); ix++) { - stdcxx::shared_ptr client - = stdcxx::dynamic_pointer_cast((*ix)->runnable()); + std::shared_ptr client + = std::dynamic_pointer_cast((*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 #include #include -#include #include "Service.h" @@ -109,8 +108,8 @@ private: class ClientThread : public Runnable { public: - ClientThread(stdcxx::shared_ptr transport, - stdcxx::shared_ptr client, + ClientThread(std::shared_ptr transport, + std::shared_ptr client, Monitor& monitor, size_t& workerCount, size_t loopCount, @@ -221,8 +220,8 @@ public: } } - stdcxx::shared_ptr _transport; - stdcxx::shared_ptr _client; + std::shared_ptr _transport; + std::shared_ptr _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 threadFactory - = stdcxx::shared_ptr(new PlatformThreadFactory()); + std::shared_ptr threadFactory + = std::shared_ptr(new PlatformThreadFactory()); // Dispatcher - stdcxx::shared_ptr serviceHandler(new Server()); + std::shared_ptr serviceHandler(new Server()); if (replayRequests) { - stdcxx::shared_ptr serviceHandler(new Server()); - stdcxx::shared_ptr serviceProcessor(new ServiceProcessor(serviceHandler)); + std::shared_ptr serviceHandler(new Server()); + std::shared_ptr serviceProcessor(new ServiceProcessor(serviceHandler)); // Transports - stdcxx::shared_ptr fileTransport(new TFileTransport(requestLogPath)); + std::shared_ptr fileTransport(new TFileTransport(requestLogPath)); fileTransport->setChunkSize(2 * 1024 * 1024); fileTransport->setMaxEventSize(1024 * 16); fileTransport->seekToEnd(); // Protocol Factory - stdcxx::shared_ptr protocolFactory(new TBinaryProtocolFactory()); + std::shared_ptr protocolFactory(new TBinaryProtocolFactory()); TFileProcessor fileProcessor(serviceProcessor, protocolFactory, fileTransport); @@ -371,50 +370,50 @@ int main(int argc, char** argv) { if (runServer) { - stdcxx::shared_ptr serviceProcessor(new ServiceProcessor(serviceHandler)); + std::shared_ptr serviceProcessor(new ServiceProcessor(serviceHandler)); // Protocol Factory - stdcxx::shared_ptr protocolFactory(new TBinaryProtocolFactory()); + std::shared_ptr protocolFactory(new TBinaryProtocolFactory()); // Transport Factory - stdcxx::shared_ptr transportFactory; + std::shared_ptr transportFactory; if (logRequests) { // initialize the log file - stdcxx::shared_ptr fileTransport(new TFileTransport(requestLogPath)); + std::shared_ptr fileTransport(new TFileTransport(requestLogPath)); fileTransport->setChunkSize(2 * 1024 * 1024); fileTransport->setMaxEventSize(1024 * 16); transportFactory - = stdcxx::shared_ptr(new TPipedTransportFactory(fileTransport)); + = std::shared_ptr(new TPipedTransportFactory(fileTransport)); } - stdcxx::shared_ptr serverThread; - stdcxx::shared_ptr serverThread2; - stdcxx::shared_ptr nbSocket1; - stdcxx::shared_ptr nbSocket2; + std::shared_ptr serverThread; + std::shared_ptr serverThread2; + std::shared_ptr nbSocket1; + std::shared_ptr nbSocket2; if (serverType == "simple") { nbSocket1.reset(new transport::TNonblockingServerSocket(port)); - serverThread = threadFactory->newThread(stdcxx::shared_ptr( + serverThread = threadFactory->newThread(std::shared_ptr( new TNonblockingServer(serviceProcessor, protocolFactory, nbSocket1))); nbSocket2.reset(new transport::TNonblockingServerSocket(port + 1)); - serverThread2 = threadFactory->newThread(stdcxx::shared_ptr( + serverThread2 = threadFactory->newThread(std::shared_ptr( new TNonblockingServer(serviceProcessor, protocolFactory, nbSocket2))); } else if (serverType == "thread-pool") { - stdcxx::shared_ptr threadManager + std::shared_ptr threadManager = ThreadManager::newSimpleThreadManager(workerCount); threadManager->threadFactory(threadFactory); threadManager->start(); nbSocket1.reset(new transport::TNonblockingServerSocket(port)); - serverThread = threadFactory->newThread(stdcxx::shared_ptr( + serverThread = threadFactory->newThread(std::shared_ptr( new TNonblockingServer(serviceProcessor, protocolFactory, nbSocket1, threadManager))); nbSocket2.reset(new transport::TNonblockingServerSocket(port + 1)); - serverThread2 = threadFactory->newThread(stdcxx::shared_ptr( + serverThread2 = threadFactory->newThread(std::shared_ptr( new TNonblockingServer(serviceProcessor, protocolFactory, nbSocket2, threadManager))); } @@ -437,7 +436,7 @@ int main(int argc, char** argv) { size_t threadCount = 0; - set > clientThreads; + set > 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 socket(new TSocket("127.0.0.1", port + (ix % 2))); - stdcxx::shared_ptr framedSocket(new TFramedTransport(socket)); - stdcxx::shared_ptr protocol(new TBinaryProtocol(framedSocket)); - stdcxx::shared_ptr serviceClient(new ServiceClient(protocol)); + std::shared_ptr socket(new TSocket("127.0.0.1", port + (ix % 2))); + std::shared_ptr framedSocket(new TFramedTransport(socket)); + std::shared_ptr protocol(new TBinaryProtocol(framedSocket)); + std::shared_ptr serviceClient(new ServiceClient(protocol)); - clientThreads.insert(threadFactory->newThread(stdcxx::shared_ptr( + clientThreads.insert(threadFactory->newThread(std::shared_ptr( new ClientThread(socket, serviceClient, monitor, threadCount, loopCount, loopType)))); } - for (std::set >::const_iterator thread = clientThreads.begin(); + for (std::set >::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 >::iterator ix = clientThreads.begin(); + for (set >::iterator ix = clientThreads.begin(); ix != clientThreads.end(); ix++) { - stdcxx::shared_ptr client - = stdcxx::dynamic_pointer_cast((*ix)->runnable()); + std::shared_ptr client + = std::dynamic_pointer_cast((*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 #include #include -#include #if _WIN32 #include #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 factory; - stdcxx::shared_ptr socket; - stdcxx::shared_ptr transport; - stdcxx::shared_ptr protocol; - stdcxx::shared_ptr protocol2; // SecondService for multiplexed + std::shared_ptr factory; + std::shared_ptr socket; + std::shared_ptr transport; + std::shared_ptr protocol; + std::shared_ptr 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(new TSSLSocketFactory()); + factory = std::shared_ptr(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(new TSocket(abstract_socket)); + socket = std::shared_ptr(new TSocket(abstract_socket)); } else { - socket = stdcxx::shared_ptr(new TSocket(domain_socket)); + socket = std::shared_ptr(new TSocket(domain_socket)); } port = 0; } else { - socket = stdcxx::shared_ptr(new TSocket(host, port)); + socket = std::shared_ptr(new TSocket(host, port)); } } if (transport_type.compare("http") == 0) { - transport = stdcxx::make_shared(socket, host, "/service"); + transport = std::make_shared(socket, host, "/service"); } else if (transport_type.compare("framed") == 0) { - transport = stdcxx::make_shared(socket); + transport = std::make_shared(socket); } else { - transport = stdcxx::make_shared(socket); + transport = std::make_shared(socket); } if (zlib) { - transport = stdcxx::make_shared(transport); + transport = std::make_shared(transport); } if (protocol_type == "json" || protocol_type == "multij") { - protocol = stdcxx::make_shared(transport); + protocol = std::make_shared(transport); } else if (protocol_type == "compact" || protocol_type == "multic") { - protocol = stdcxx::make_shared(transport); + protocol = std::make_shared(transport); } else if (protocol_type == "header" || protocol_type == "multih") { - protocol = stdcxx::make_shared(transport); + protocol = std::make_shared(transport); } else { - protocol = stdcxx::make_shared(transport); + protocol = std::make_shared(transport); } if (boost::starts_with(protocol_type, "multi")) { - protocol2 = stdcxx::make_shared(protocol, "SecondService"); + protocol2 = std::make_shared(protocol, "SecondService"); // we don't need access to the original protocol any more, so... - protocol = stdcxx::make_shared(protocol, "ThriftTest"); + protocol = std::make_shared(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 protocolFactory(new TBinaryProtocolFactory()); + std::shared_ptr protocolFactory(new TBinaryProtocolFactory()); - stdcxx::shared_ptr channel( + std::shared_ptr 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 #include #include -#include #if _WIN32 #include @@ -395,66 +394,66 @@ class TestProcessorEventHandler : public TProcessorEventHandler { class TestHandlerAsync : public ThriftTestCobSvIf { public: - TestHandlerAsync(stdcxx::shared_ptr& handler) : _delegate(handler) {} + TestHandlerAsync(std::shared_ptr& handler) : _delegate(handler) {} virtual ~TestHandlerAsync() {} - virtual void testVoid(stdcxx::function cob) { + virtual void testVoid(std::function cob) { _delegate->testVoid(); cob(); } - virtual void testString(stdcxx::function cob, + virtual void testString(std::function cob, const std::string& thing) { std::string res; _delegate->testString(res, thing); cob(res); } - virtual void testBool(stdcxx::function cob, const bool thing) { + virtual void testBool(std::function cob, const bool thing) { bool res = _delegate->testBool(thing); cob(res); } - virtual void testByte(stdcxx::function cob, const int8_t thing) { + virtual void testByte(std::function cob, const int8_t thing) { int8_t res = _delegate->testByte(thing); cob(res); } - virtual void testI32(stdcxx::function cob, const int32_t thing) { + virtual void testI32(std::function cob, const int32_t thing) { int32_t res = _delegate->testI32(thing); cob(res); } - virtual void testI64(stdcxx::function cob, const int64_t thing) { + virtual void testI64(std::function cob, const int64_t thing) { int64_t res = _delegate->testI64(thing); cob(res); } - virtual void testDouble(stdcxx::function cob, const double thing) { + virtual void testDouble(std::function cob, const double thing) { double res = _delegate->testDouble(thing); cob(res); } - virtual void testBinary(stdcxx::function cob, + virtual void testBinary(std::function cob, const std::string& thing) { std::string res; _delegate->testBinary(res, thing); cob(res); } - virtual void testStruct(stdcxx::function cob, const Xtruct& thing) { + virtual void testStruct(std::function cob, const Xtruct& thing) { Xtruct res; _delegate->testStruct(res, thing); cob(res); } - virtual void testNest(stdcxx::function cob, const Xtruct2& thing) { + virtual void testNest(std::function cob, const Xtruct2& thing) { Xtruct2 res; _delegate->testNest(res, thing); cob(res); } - virtual void testMap(stdcxx::function const& _return)> cob, + virtual void testMap(std::function const& _return)> cob, const std::map& thing) { std::map res; _delegate->testMap(res, thing); @@ -462,40 +461,40 @@ public: } virtual void testStringMap( - stdcxx::function const& _return)> cob, + std::function const& _return)> cob, const std::map& thing) { std::map res; _delegate->testStringMap(res, thing); cob(res); } - virtual void testSet(stdcxx::function const& _return)> cob, + virtual void testSet(std::function const& _return)> cob, const std::set& thing) { std::set res; _delegate->testSet(res, thing); cob(res); } - virtual void testList(stdcxx::function const& _return)> cob, + virtual void testList(std::function const& _return)> cob, const std::vector& thing) { std::vector res; _delegate->testList(res, thing); cob(res); } - virtual void testEnum(stdcxx::function cob, + virtual void testEnum(std::function cob, const Numberz::type thing) { Numberz::type res = _delegate->testEnum(thing); cob(res); } - virtual void testTypedef(stdcxx::function cob, const UserId thing) { + virtual void testTypedef(std::function cob, const UserId thing) { UserId res = _delegate->testTypedef(thing); cob(res); } virtual void testMapMap( - stdcxx::function > const& _return)> cob, + std::function > const& _return)> cob, const int32_t hello) { std::map > res; _delegate->testMapMap(res, hello); @@ -503,14 +502,14 @@ public: } virtual void testInsanity( - stdcxx::function > const& _return)> cob, + std::function > const& _return)> cob, const Insanity& argument) { std::map > res; _delegate->testInsanity(res, argument); cob(res); } - virtual void testMulti(stdcxx::function cob, + virtual void testMulti(std::function cob, const int8_t arg0, const int32_t arg1, const int64_t arg2, @@ -523,8 +522,8 @@ public: } virtual void testException( - stdcxx::function cob, - stdcxx::function exn_cob, + std::function cob, + std::function exn_cob, const std::string& arg) { try { _delegate->testException(arg); @@ -536,8 +535,8 @@ public: } virtual void testMultiException( - stdcxx::function cob, - stdcxx::function exn_cob, + std::function cob, + std::function exn_cob, const std::string& arg0, const std::string& arg1) { Xtruct res; @@ -550,13 +549,13 @@ public: cob(res); } - virtual void testOneway(stdcxx::function cob, const int32_t secondsToSleep) { + virtual void testOneway(std::function cob, const int32_t secondsToSleep) { _delegate->testOneway(secondsToSleep); cob(); } protected: - stdcxx::shared_ptr _delegate; + std::shared_ptr _delegate; }; namespace po = boost::program_options; @@ -668,9 +667,9 @@ int main(int argc, char** argv) { } // Dispatcher - stdcxx::shared_ptr protocolFactory; + std::shared_ptr protocolFactory; if (protocol_type == "json" || protocol_type == "multij") { - stdcxx::shared_ptr jsonProtocolFactory(new TJSONProtocolFactory()); + std::shared_ptr jsonProtocolFactory(new TJSONProtocolFactory()); protocolFactory = jsonProtocolFactory; } else if (protocol_type == "compact" || protocol_type == "multic") { TCompactProtocolFactoryT *compactProtocolFactory = new TCompactProtocolFactoryT(); @@ -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 headerProtocolFactory(new THeaderProtocolFactory()); + std::shared_ptr headerProtocolFactory(new THeaderProtocolFactory()); protocolFactory = headerProtocolFactory; } else { TBinaryProtocolFactoryT* binaryProtocolFactory = new TBinaryProtocolFactoryT(); @@ -688,56 +687,56 @@ int main(int argc, char** argv) { } // Processors - stdcxx::shared_ptr testHandler(new TestHandler()); - stdcxx::shared_ptr testProcessor(new ThriftTestProcessor(testHandler)); + std::shared_ptr testHandler(new TestHandler()); + std::shared_ptr testProcessor(new ThriftTestProcessor(testHandler)); if (vm.count("processor-events")) { testProcessor->setEventHandler( - stdcxx::shared_ptr(new TestProcessorEventHandler())); + std::shared_ptr(new TestProcessorEventHandler())); } // Transport - stdcxx::shared_ptr sslSocketFactory; - stdcxx::shared_ptr serverSocket; + std::shared_ptr sslSocketFactory; + std::shared_ptr serverSocket; if (ssl) { - sslSocketFactory = stdcxx::shared_ptr(new TSSLSocketFactory()); + sslSocketFactory = std::shared_ptr(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(new TSSLServerSocket(port, sslSocketFactory)); + serverSocket = std::shared_ptr(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(new TServerSocket(abstract_socket)); + serverSocket = std::shared_ptr(new TServerSocket(abstract_socket)); } else { unlink(domain_socket.c_str()); - serverSocket = stdcxx::shared_ptr(new TServerSocket(domain_socket)); + serverSocket = std::shared_ptr(new TServerSocket(domain_socket)); } port = 0; } else { - serverSocket = stdcxx::shared_ptr(new TServerSocket(port)); + serverSocket = std::shared_ptr(new TServerSocket(port)); } } // Factory - stdcxx::shared_ptr transportFactory; + std::shared_ptr transportFactory; if (transport_type == "http" && server_type != "nonblocking") { - transportFactory = stdcxx::make_shared(); + transportFactory = std::make_shared(); } else if (transport_type == "framed") { - transportFactory = stdcxx::make_shared(); + transportFactory = std::make_shared(); } else { - transportFactory = stdcxx::make_shared(); + transportFactory = std::make_shared(); } if (zlib) { // hmm.. doesn't seem to be a way to make it wrap the others... - transportFactory = stdcxx::make_shared(); + transportFactory = std::make_shared(); } // 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(new SecondHandler()); - stdcxx::shared_ptr secondProcessor(new SecondServiceProcessor(secondHandler)); + std::shared_ptr secondHandler(new SecondHandler()); + std::shared_ptr secondProcessor(new SecondServiceProcessor(secondHandler)); - stdcxx::shared_ptr multiplexedProcessor(new TMultiplexedProcessor()); + std::shared_ptr 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(multiplexedProcessor); + testProcessor = std::dynamic_pointer_cast(multiplexedProcessor); } // Server - stdcxx::shared_ptr server; + std::shared_ptr server; if (server_type == "simple") { server.reset(new TSimpleServer(testProcessor, serverSocket, transportFactory, protocolFactory)); } else if (server_type == "thread-pool") { - stdcxx::shared_ptr threadFactory - = stdcxx::shared_ptr(new PlatformThreadFactory()); + std::shared_ptr threadFactory + = std::shared_ptr(new PlatformThreadFactory()); - stdcxx::shared_ptr threadManager = ThreadManager::newSimpleThreadManager(workers); + std::shared_ptr 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(new TestHandlerAsync(testHandler)); - stdcxx::shared_ptr testProcessorAsync( + std::shared_ptr testHandlerAsync(new TestHandlerAsync(testHandler)); + std::shared_ptr testProcessorAsync( new ThriftTestAsyncProcessor(testHandlerAsync)); - stdcxx::shared_ptr testBufferProcessor( + std::shared_ptr 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 nbSocket; + std::shared_ptr 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()); + server->setOutputProtocolFactory(std::shared_ptr()); } apache::thrift::concurrency::PlatformThreadFactory factory; factory.setDetached(false); - stdcxx::shared_ptr serverThreadRunner(server); - stdcxx::shared_ptr thread + std::shared_ptr serverThreadRunner(server); + std::shared_ptr thread = factory.newThread(serverThreadRunner); #ifdef HAVE_SIGNAL_H -- cgit v1.2.1