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 /tutorial/cpp | |
parent | 52637b33aba090851436b2031476529423ea3281 (diff) | |
download | thrift-316723add4c368ffd144dd5beb55245832e073fa.tar.gz |
remove stdcxx namespace and use std directly
Diffstat (limited to 'tutorial/cpp')
-rw-r--r-- | tutorial/cpp/CppClient.cpp | 7 | ||||
-rw-r--r-- | tutorial/cpp/CppServer.cpp | 39 |
2 files changed, 22 insertions, 24 deletions
diff --git a/tutorial/cpp/CppClient.cpp b/tutorial/cpp/CppClient.cpp index f10c72557..520841143 100644 --- a/tutorial/cpp/CppClient.cpp +++ b/tutorial/cpp/CppClient.cpp @@ -22,7 +22,6 @@ #include <thrift/protocol/TBinaryProtocol.h> #include <thrift/transport/TSocket.h> #include <thrift/transport/TTransportUtils.h> -#include <thrift/stdcxx.h> #include "../gen-cpp/Calculator.h" @@ -35,9 +34,9 @@ using namespace tutorial; using namespace shared; int main() { - stdcxx::shared_ptr<TTransport> socket(new TSocket("localhost", 9090)); - stdcxx::shared_ptr<TTransport> transport(new TBufferedTransport(socket)); - stdcxx::shared_ptr<TProtocol> protocol(new TBinaryProtocol(transport)); + std::shared_ptr<TTransport> socket(new TSocket("localhost", 9090)); + std::shared_ptr<TTransport> transport(new TBufferedTransport(socket)); + std::shared_ptr<TProtocol> protocol(new TBinaryProtocol(transport)); CalculatorClient client(protocol); try { diff --git a/tutorial/cpp/CppServer.cpp b/tutorial/cpp/CppServer.cpp index 80b100e59..f7379d536 100644 --- a/tutorial/cpp/CppServer.cpp +++ b/tutorial/cpp/CppServer.cpp @@ -27,7 +27,6 @@ #include <thrift/transport/TSocket.h> #include <thrift/transport/TTransportUtils.h> #include <thrift/TToString.h> -#include <thrift/stdcxx.h> #include <iostream> #include <stdexcept> @@ -117,7 +116,7 @@ class CalculatorCloneFactory : virtual public CalculatorIfFactory { virtual ~CalculatorCloneFactory() {} virtual CalculatorIf* getHandler(const ::apache::thrift::TConnectionInfo& connInfo) { - stdcxx::shared_ptr<TSocket> sock = stdcxx::dynamic_pointer_cast<TSocket>(connInfo.transport); + std::shared_ptr<TSocket> sock = std::dynamic_pointer_cast<TSocket>(connInfo.transport); cout << "Incoming connection\n"; cout << "\tSocketInfo: " << sock->getSocketInfo() << "\n"; cout << "\tPeerHost: " << sock->getPeerHost() << "\n"; @@ -132,18 +131,18 @@ class CalculatorCloneFactory : virtual public CalculatorIfFactory { int main() { TThreadedServer server( - stdcxx::make_shared<CalculatorProcessorFactory>(stdcxx::make_shared<CalculatorCloneFactory>()), - stdcxx::make_shared<TServerSocket>(9090), //port - stdcxx::make_shared<TBufferedTransportFactory>(), - stdcxx::make_shared<TBinaryProtocolFactory>()); + std::make_shared<CalculatorProcessorFactory>(std::make_shared<CalculatorCloneFactory>()), + std::make_shared<TServerSocket>(9090), //port + std::make_shared<TBufferedTransportFactory>(), + std::make_shared<TBinaryProtocolFactory>()); /* // if you don't need per-connection state, do the following instead TThreadedServer server( - stdcxx::make_shared<CalculatorProcessor>(stdcxx::make_shared<CalculatorHandler>()), - stdcxx::make_shared<TServerSocket>(9090), //port - stdcxx::make_shared<TBufferedTransportFactory>(), - stdcxx::make_shared<TBinaryProtocolFactory>()); + std::make_shared<CalculatorProcessor>(std::make_shared<CalculatorHandler>()), + std::make_shared<TServerSocket>(9090), //port + std::make_shared<TBufferedTransportFactory>(), + std::make_shared<TBinaryProtocolFactory>()); */ /** @@ -151,25 +150,25 @@ int main() { // This server only allows one connection at a time, but spawns no threads TSimpleServer server( - stdcxx::make_shared<CalculatorProcessor>(stdcxx::make_shared<CalculatorHandler>()), - stdcxx::make_shared<TServerSocket>(9090), - stdcxx::make_shared<TBufferedTransportFactory>(), - stdcxx::make_shared<TBinaryProtocolFactory>()); + std::make_shared<CalculatorProcessor>(std::make_shared<CalculatorHandler>()), + std::make_shared<TServerSocket>(9090), + std::make_shared<TBufferedTransportFactory>(), + std::make_shared<TBinaryProtocolFactory>()); const int workerCount = 4; - stdcxx::shared_ptr<ThreadManager> threadManager = + std::shared_ptr<ThreadManager> threadManager = ThreadManager::newSimpleThreadManager(workerCount); threadManager->threadFactory( - stdcxx::make_shared<PlatformThreadFactory>()); + std::make_shared<PlatformThreadFactory>()); threadManager->start(); // This server allows "workerCount" connection at a time, and reuses threads TThreadPoolServer server( - stdcxx::make_shared<CalculatorProcessorFactory>(stdcxx::make_shared<CalculatorCloneFactory>()), - stdcxx::make_shared<TServerSocket>(9090), - stdcxx::make_shared<TBufferedTransportFactory>(), - stdcxx::make_shared<TBinaryProtocolFactory>(), + std::make_shared<CalculatorProcessorFactory>(std::make_shared<CalculatorCloneFactory>()), + std::make_shared<TServerSocket>(9090), + std::make_shared<TBufferedTransportFactory>(), + std::make_shared<TBinaryProtocolFactory>(), threadManager); */ |