THRIFT-2221: detect C++11 and use std namespace for memory operations (smart_ptr) Client: C++
This closes #1328 Project: http://git-wip-us.apache.org/repos/asf/thrift/repo Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/82ae9575 Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/82ae9575 Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/82ae9575 Branch: refs/heads/master Commit: 82ae9575cdc112088771fc7b876f75e1e4d85ebb Parents: 0a8c34c Author: James E. King, III <jim.k...@simplivity.com> Authored: Sat Aug 5 12:23:54 2017 -0400 Committer: James E. King, III <jk...@apache.org> Committed: Thu Aug 10 13:27:21 2017 -0400 ---------------------------------------------------------------------- appveyor.yml | 8 +- build/appveyor/MSVC-appveyor-build.bat | 2 + build/cmake/DefineCMakeDefaults.cmake | 12 +- build/cmake/DefineOptions.cmake | 12 ++ build/cmake/DefinePlatformSpecifc.cmake | 15 +- build/cmake/NewPlatformDebug.cmake | 1 + .../cpp/src/thrift/generate/t_cpp_generator.cc | 118 ++++++------ compiler/cpp/src/thrift/plugin/plugin.cc | 30 ++-- compiler/cpp/src/thrift/plugin/plugin_output.cc | 8 +- lib/c_glib/test/testthrifttestclient.cpp | 37 ++-- lib/cpp/Makefile.am | 4 +- lib/cpp/README.md | 31 ++-- lib/cpp/src/thrift/TDispatchProcessor.h | 8 +- lib/cpp/src/thrift/TProcessor.h | 34 ++-- .../src/thrift/async/TAsyncBufferProcessor.h | 10 +- lib/cpp/src/thrift/async/TAsyncChannel.cpp | 2 +- lib/cpp/src/thrift/async/TAsyncChannel.h | 2 +- .../src/thrift/async/TAsyncDispatchProcessor.h | 8 +- lib/cpp/src/thrift/async/TAsyncProcessor.h | 24 ++- .../thrift/async/TAsyncProtocolProcessor.cpp | 10 +- .../src/thrift/async/TAsyncProtocolProcessor.h | 14 +- .../thrift/async/TConcurrentClientSyncInfo.h | 4 +- lib/cpp/src/thrift/async/TEvhttpClientChannel.h | 2 +- lib/cpp/src/thrift/async/TEvhttpServer.cpp | 14 +- lib/cpp/src/thrift/async/TEvhttpServer.h | 8 +- lib/cpp/src/thrift/concurrency/BoostMonitor.cpp | 6 +- .../thrift/concurrency/BoostThreadFactory.cpp | 17 +- .../src/thrift/concurrency/BoostThreadFactory.h | 9 +- lib/cpp/src/thrift/concurrency/FunctionRunner.h | 16 +- lib/cpp/src/thrift/concurrency/Monitor.cpp | 9 +- lib/cpp/src/thrift/concurrency/Mutex.cpp | 2 - lib/cpp/src/thrift/concurrency/Mutex.h | 6 +- .../thrift/concurrency/PosixThreadFactory.cpp | 29 ++- .../src/thrift/concurrency/PosixThreadFactory.h | 10 +- .../src/thrift/concurrency/StdThreadFactory.cpp | 22 ++- .../src/thrift/concurrency/StdThreadFactory.h | 8 +- lib/cpp/src/thrift/concurrency/Thread.h | 17 +- .../src/thrift/concurrency/ThreadManager.cpp | 10 +- lib/cpp/src/thrift/concurrency/ThreadManager.h | 19 +- lib/cpp/src/thrift/concurrency/TimerManager.cpp | 2 +- lib/cpp/src/thrift/concurrency/TimerManager.h | 24 +-- lib/cpp/src/thrift/cxxfunctional.h | 132 -------------- lib/cpp/src/thrift/processor/PeekProcessor.cpp | 26 +-- lib/cpp/src/thrift/processor/PeekProcessor.h | 30 ++-- lib/cpp/src/thrift/processor/StatsProcessor.h | 8 +- .../thrift/processor/TMultiplexedProcessor.h | 2 +- lib/cpp/src/thrift/protocol/TBinaryProtocol.h | 12 +- lib/cpp/src/thrift/protocol/TCompactProtocol.h | 12 +- lib/cpp/src/thrift/protocol/TDebugProtocol.h | 12 +- lib/cpp/src/thrift/protocol/THeaderProtocol.cpp | 6 +- lib/cpp/src/thrift/protocol/THeaderProtocol.h | 34 ++-- lib/cpp/src/thrift/protocol/TJSONProtocol.cpp | 12 +- lib/cpp/src/thrift/protocol/TJSONProtocol.h | 14 +- .../src/thrift/protocol/TMultiplexedProtocol.h | 2 +- lib/cpp/src/thrift/protocol/TProtocol.h | 18 +- .../src/thrift/protocol/TProtocolDecorator.h | 4 +- lib/cpp/src/thrift/protocol/TProtocolTap.h | 6 +- lib/cpp/src/thrift/protocol/TVirtualProtocol.h | 4 +- lib/cpp/src/thrift/qt/TQIODeviceTransport.cpp | 6 +- lib/cpp/src/thrift/qt/TQIODeviceTransport.h | 6 +- lib/cpp/src/thrift/qt/TQTcpServer.cpp | 9 +- lib/cpp/src/thrift/qt/TQTcpServer.h | 18 +- lib/cpp/src/thrift/server/TConnectedClient.cpp | 2 +- lib/cpp/src/thrift/server/TConnectedClient.h | 22 +-- .../src/thrift/server/TNonblockingServer.cpp | 64 +++---- lib/cpp/src/thrift/server/TNonblockingServer.h | 94 +++++----- lib/cpp/src/thrift/server/TServer.h | 140 +++++++-------- lib/cpp/src/thrift/server/TServerFramework.cpp | 13 +- lib/cpp/src/thrift/server/TServerFramework.h | 46 ++--- lib/cpp/src/thrift/server/TSimpleServer.cpp | 2 +- lib/cpp/src/thrift/server/TSimpleServer.h | 42 ++--- lib/cpp/src/thrift/server/TThreadPoolServer.cpp | 4 +- lib/cpp/src/thrift/server/TThreadPoolServer.h | 54 +++--- lib/cpp/src/thrift/server/TThreadedServer.cpp | 14 +- lib/cpp/src/thrift/server/TThreadedServer.h | 66 +++---- lib/cpp/src/thrift/stdcxx.h | 124 +++++++++++++ .../src/thrift/transport/TBufferTransports.h | 26 +-- lib/cpp/src/thrift/transport/TFDTransport.cpp | 2 +- lib/cpp/src/thrift/transport/TFileTransport.cpp | 5 +- lib/cpp/src/thrift/transport/TFileTransport.h | 37 ++-- .../src/thrift/transport/THeaderTransport.cpp | 7 +- lib/cpp/src/thrift/transport/THeaderTransport.h | 14 +- lib/cpp/src/thrift/transport/THttpClient.cpp | 8 +- lib/cpp/src/thrift/transport/THttpClient.h | 2 +- lib/cpp/src/thrift/transport/THttpServer.cpp | 6 +- lib/cpp/src/thrift/transport/THttpServer.h | 6 +- lib/cpp/src/thrift/transport/THttpTransport.cpp | 6 +- lib/cpp/src/thrift/transport/THttpTransport.h | 4 +- .../transport/TNonblockingSSLServerSocket.cpp | 10 +- .../transport/TNonblockingSSLServerSocket.h | 12 +- .../transport/TNonblockingServerSocket.cpp | 5 +- .../thrift/transport/TNonblockingServerSocket.h | 7 +- .../transport/TNonblockingServerTransport.h | 8 +- lib/cpp/src/thrift/transport/TPipe.cpp | 7 +- lib/cpp/src/thrift/transport/TPipe.h | 2 +- lib/cpp/src/thrift/transport/TPipeServer.cpp | 15 +- lib/cpp/src/thrift/transport/TPipeServer.h | 6 +- .../src/thrift/transport/TSSLServerSocket.cpp | 8 +- lib/cpp/src/thrift/transport/TSSLServerSocket.h | 12 +- lib/cpp/src/thrift/transport/TSSLSocket.cpp | 44 ++--- lib/cpp/src/thrift/transport/TSSLSocket.h | 45 ++--- lib/cpp/src/thrift/transport/TServerSocket.cpp | 9 +- lib/cpp/src/thrift/transport/TServerSocket.h | 11 +- lib/cpp/src/thrift/transport/TServerTransport.h | 8 +- .../src/thrift/transport/TShortReadTransport.h | 6 +- lib/cpp/src/thrift/transport/TSocket.cpp | 6 +- lib/cpp/src/thrift/transport/TSocket.h | 4 +- lib/cpp/src/thrift/transport/TSocketPool.cpp | 8 +- lib/cpp/src/thrift/transport/TSocketPool.h | 14 +- lib/cpp/src/thrift/transport/TTransport.h | 4 +- .../src/thrift/transport/TTransportUtils.cpp | 4 +- lib/cpp/src/thrift/transport/TTransportUtils.h | 44 ++--- lib/cpp/src/thrift/transport/TZlibTransport.h | 8 +- lib/cpp/src/thrift/windows/TWinsockSingleton.h | 5 +- lib/cpp/test/AllProtocolTests.tcc | 2 +- lib/cpp/test/Benchmark.cpp | 21 +-- lib/cpp/test/CMakeLists.txt | 18 +- lib/cpp/test/DebugProtoTest.cpp | 8 +- lib/cpp/test/GenericHelpers.h | 31 ++-- lib/cpp/test/JSONProtoTest.cpp | 39 ++-- lib/cpp/test/OpenSSLManualInitTest.cpp | 1 - lib/cpp/test/OptionalRequiredTest.cpp | 6 +- lib/cpp/test/RecursiveTest.cpp | 15 +- lib/cpp/test/SecurityTest.cpp | 63 +++---- lib/cpp/test/SpecializationTest.cpp | 4 +- lib/cpp/test/TBufferBaseTest.cpp | 5 +- lib/cpp/test/TMemoryBufferTest.cpp | 5 +- lib/cpp/test/TNonblockingSSLServerTest.cpp | 42 ++--- lib/cpp/test/TNonblockingServerTest.cpp | 47 ++--- lib/cpp/test/TPipeInterruptTest.cpp | 9 +- lib/cpp/test/TPipedTransportTest.cpp | 8 +- lib/cpp/test/TSSLSocketInterruptTest.cpp | 78 ++++---- lib/cpp/test/TServerIntegrationTest.cpp | 105 +++++------ lib/cpp/test/TServerSocketTest.cpp | 4 +- lib/cpp/test/TServerTransportTest.cpp | 8 +- lib/cpp/test/TSocketInterruptTest.cpp | 25 +-- lib/cpp/test/TransportTest.cpp | 55 ++++-- lib/cpp/test/ZlibTest.cpp | 47 ++--- lib/cpp/test/concurrency/RWMutexStarveTest.cpp | 27 ++- lib/cpp/test/concurrency/ThreadFactoryTests.h | 2 +- lib/cpp/test/concurrency/ThreadManagerTests.h | 4 +- lib/cpp/test/processor/EventLog.cpp | 3 +- lib/cpp/test/processor/Handlers.h | 32 ++-- lib/cpp/test/processor/ProcessorTest.cpp | 178 +++++++++---------- lib/cpp/test/processor/ServerThread.cpp | 2 +- lib/cpp/test/processor/ServerThread.h | 16 +- lib/cpp/test/qt/TQTcpServerTest.cpp | 42 ++--- test/cpp/src/StressTest.cpp | 83 ++++----- test/cpp/src/StressTestNonBlocking.cpp | 73 ++++---- test/cpp/src/TestClient.cpp | 47 +++-- test/cpp/src/TestServer.cpp | 112 ++++++------ tutorial/cpp/CppClient.cpp | 7 +- tutorial/cpp/CppServer.cpp | 41 +++-- 153 files changed, 1762 insertions(+), 1672 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/thrift/blob/82ae9575/appveyor.yml ---------------------------------------------------------------------- diff --git a/appveyor.yml b/appveyor.yml index 42c2911..fc09f87 100755 --- a/appveyor.yml +++ b/appveyor.yml @@ -45,7 +45,7 @@ environment: - PROFILE: MSVC2015 PLATFORM: x64 CONFIGURATION: Release - BOOST_VERSION: 1.63.0 + BOOST_VERSION: 1.64.0 LIBEVENT_VERSION: 2.0.22 PYTHON_VERSION: 3.6 QT_VERSION: 5.8 @@ -92,6 +92,10 @@ test_script: # # enables RDP at the end of the build job so you can login and re-run # commands to see why something failed... -# on_finish: +#on_finish: # - ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1')) +# +# also need: +# environment: +# APPVEYOR_RDP_PASSWORD: thr1FT2345$xyzZ http://git-wip-us.apache.org/repos/asf/thrift/blob/82ae9575/build/appveyor/MSVC-appveyor-build.bat ---------------------------------------------------------------------- diff --git a/build/appveyor/MSVC-appveyor-build.bat b/build/appveyor/MSVC-appveyor-build.bat index 054a8b4..a4b92a2 100644 --- a/build/appveyor/MSVC-appveyor-build.bat +++ b/build/appveyor/MSVC-appveyor-build.bat @@ -24,10 +24,12 @@ CD "%BUILDDIR%" || EXIT /B @ECHO ON cmake "%SRCDIR%" ^ -G"%GENERATOR%" ^ + -DBISON_EXECUTABLE=C:\ProgramData\chocolatey\lib\winflexbison3\tools\win_bison.exe ^ -DBOOST_ROOT="%BOOST_ROOT%" ^ -DBOOST_LIBRARYDIR="%BOOST_LIBRARYDIR%" ^ -DCMAKE_BUILD_TYPE="%CONFIGURATION%" ^ -DCMAKE_INSTALL_PREFIX="%INSTDIR%" ^ + -DFLEX_EXECUTABLE=C:\ProgramData\chocolatey\lib\winflexbison3\tools\win_flex.exe ^ -DINTTYPES_ROOT="%WIN3P%\msinttypes" ^ -DLIBEVENT_ROOT="%WIN3P%\libevent-%LIBEVENT_VERSION%-stable" ^ -DOPENSSL_ROOT_DIR="%OPENSSL_ROOT%" ^ http://git-wip-us.apache.org/repos/asf/thrift/blob/82ae9575/build/cmake/DefineCMakeDefaults.cmake ---------------------------------------------------------------------- diff --git a/build/cmake/DefineCMakeDefaults.cmake b/build/cmake/DefineCMakeDefaults.cmake index 365c0a4..2899937 100644 --- a/build/cmake/DefineCMakeDefaults.cmake +++ b/build/cmake/DefineCMakeDefaults.cmake @@ -70,11 +70,17 @@ set(CMAKE_MACOSX_RPATH TRUE) set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) # -# C++ Language Level Defaults +# C++ Language Level Defaults - this depends on the compiler capabilities # if (NOT DEFINED CMAKE_CXX_STANDARD) - set(CMAKE_CXX_STANDARD 11) # C++11 - message(STATUS "Setting C++11 as the default language level.") + if (MSVC AND MSVC_VERSION LESS 1800) + # MSVC 2012 and earlier don't support template aliases so you have to use C++98 + set(CMAKE_CXX_STANDARD 98) + message(STATUS "Setting C++98 as the default language level (for an older MSVC compiler).") + else() + set(CMAKE_CXX_STANDARD 11) # C++11 + message(STATUS "Setting C++11 as the default language level.") + endif() message(STATUS "To specify a different C++ language level, set CMAKE_CXX_STANDARD") endif() http://git-wip-us.apache.org/repos/asf/thrift/blob/82ae9575/build/cmake/DefineOptions.cmake ---------------------------------------------------------------------- diff --git a/build/cmake/DefineOptions.cmake b/build/cmake/DefineOptions.cmake index 63981e9..f1ea7bb 100644 --- a/build/cmake/DefineOptions.cmake +++ b/build/cmake/DefineOptions.cmake @@ -40,6 +40,16 @@ option(BUILD_LIBRARIES "Build Thrift libraries" ON) # and enables the library if all are found. This means the default is to build as # much as possible but leaving out libraries if their dependencies are not met. +option(WITH_BOOST_FUNCTIONAL "Use boost/tr1/functional.hpp even under C++11 or later" OFF) +if (WITH_BOOST_FUNCTIONAL) + add_definitions(-DFORCE_BOOST_FUNCTIONAL) +endif() + +option(WITH_BOOST_SMART_PTR "Use boost/smart_ptr.hpp even under C++11 or later" OFF) +if (WITH_BOOST_SMART_PTR) + add_definitions(-DFORCE_BOOST_SMART_PTR) +endif() + option(WITH_BOOST_STATIC "Build with Boost static link library" OFF) set(Boost_USE_STATIC_LIBS ${WITH_BOOST_STATIC}) if (NOT WITH_BOOST_STATIC) @@ -197,6 +207,8 @@ message(STATUS " Build shared libraries: ${WITH_SHARED_LIB} message(STATUS " Build static libraries: ${WITH_STATIC_LIB}") message(STATUS " Build with Boost static link library: ${WITH_BOOST_STATIC}") message(STATUS " Build with Boost thread support: ${WITH_BOOSTTHREADS}") +message(STATUS " Build with boost/tr1/functional (forced) ${WITH_BOOST_FUNCTIONAL}") +message(STATUS " Build with boost/smart_ptr (forced) ${WITH_BOOST_SMART_PTR}") message(STATUS " Build with C++ std::thread support: ${WITH_STDTHREADS}") message(STATUS " Build with libevent support: ${WITH_LIBEVENT}") message(STATUS " Build with OpenSSL support: ${WITH_OPENSSL}") http://git-wip-us.apache.org/repos/asf/thrift/blob/82ae9575/build/cmake/DefinePlatformSpecifc.cmake ---------------------------------------------------------------------- diff --git a/build/cmake/DefinePlatformSpecifc.cmake b/build/cmake/DefinePlatformSpecifc.cmake index d5d27e2..f443489 100644 --- a/build/cmake/DefinePlatformSpecifc.cmake +++ b/build/cmake/DefinePlatformSpecifc.cmake @@ -109,7 +109,10 @@ if (CMAKE_CXX_EXTENSIONS) string(CONCAT CXX_LANGUAGE_LEVEL "${CXX_LANGUAGE_LEVEL} [with compiler-specific extensions]") else() if ((CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") AND NOT MINGW) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-variadic-macros -Wno-long-long -Wno-c++11-long-long") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-variadic-macros -Wno-long-long") + endif() + if ((CMAKE_CXX_COMPILER_ID MATCHES "Clang") AND NOT MINGW) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-c++11-long-long") endif() endif() @@ -117,8 +120,12 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-register") endif() -# If gcc older than 4.8 is detected and plugin support was requested, fail fast -if (CMAKE_CXX_COMPILER_ID MATCHES "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.8" AND WITH_PLUGIN) - message(SEND_ERROR "Thrift compiler plug-in support is not possible with older gcc ( < 4.8 ) compiler") +# Building WITH_PLUGIN requires boost memory operations, for now, and gcc >= 4.8 +if (WITH_PLUGIN) + if (CMAKE_CXX_COMPILER_ID MATCHES "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.8") + message(SEND_ERROR "Thrift compiler plug-in support is not possible with older gcc ( < 4.8 ) compiler") + endif() + message(STATUS "Forcing use of boost::smart_ptr to build WITH_PLUGIN") + add_definitions("-DFORCE_BOOST_SMART_PTR=1") endif() http://git-wip-us.apache.org/repos/asf/thrift/blob/82ae9575/build/cmake/NewPlatformDebug.cmake ---------------------------------------------------------------------- diff --git a/build/cmake/NewPlatformDebug.cmake b/build/cmake/NewPlatformDebug.cmake index 76cac15..aa4d302 100644 --- a/build/cmake/NewPlatformDebug.cmake +++ b/build/cmake/NewPlatformDebug.cmake @@ -36,6 +36,7 @@ if(NEWPLATFORMDEBUG) SHOWFLAG("CYGWIN") SHOWFLAG("MINGW") SHOWFLAG("MSVC") + SHOWFLAG("MSVC_VERSION") SHOWFLAG("MSYS") SHOWFLAG("UNIX") SHOWFLAG("WATCOM") http://git-wip-us.apache.org/repos/asf/thrift/blob/82ae9575/compiler/cpp/src/thrift/generate/t_cpp_generator.cc ---------------------------------------------------------------------- diff --git a/compiler/cpp/src/thrift/generate/t_cpp_generator.cc b/compiler/cpp/src/thrift/generate/t_cpp_generator.cc index 0518ec8..9413b86 100644 --- a/compiler/cpp/src/thrift/generate/t_cpp_generator.cc +++ b/compiler/cpp/src/thrift/generate/t_cpp_generator.cc @@ -409,7 +409,7 @@ void t_cpp_generator::init_generator() { << "#include <thrift/transport/TTransport.h>" << endl << endl; // Include C++xx compatibility header - f_types_ << "#include <thrift/cxxfunctional.h>" << endl; + f_types_ << "#include <thrift/stdcxx.h>" << endl; // Include other Thrift includes const vector<t_program*>& includes = program_->get_includes(); @@ -1108,7 +1108,7 @@ void t_cpp_generator::generate_struct_declaration(ofstream& out, continue; } if (is_reference((*m_iter))) { - out << endl << indent() << "void __set_" << (*m_iter)->get_name() << "(boost::shared_ptr<" + out << endl << indent() << "void __set_" << (*m_iter)->get_name() << "(::apache::thrift::stdcxx::shared_ptr<" << type_name((*m_iter)->get_type(), false, false) << ">"; out << " val);" << endl; } else { @@ -1228,7 +1228,7 @@ void t_cpp_generator::generate_struct_definition(ofstream& out, if (is_reference((*m_iter))) { std::string type = type_name((*m_iter)->get_type()); out << endl << indent() << "void " << tstruct->get_name() << "::__set_" - << (*m_iter)->get_name() << "(boost::shared_ptr<" + << (*m_iter)->get_name() << "(::apache::thrift::stdcxx::shared_ptr<" << type_name((*m_iter)->get_type(), false, false) << ">"; out << " val) {" << endl; } else { @@ -1276,7 +1276,7 @@ void t_cpp_generator::generate_struct_reader(ofstream& out, t_struct* tstruct, b // Declare stack tmp variables out << endl - << indent() << "apache::thrift::protocol::TInputRecursionTracker tracker(*iprot);" << endl + << indent() << "::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot);" << endl << indent() << "uint32_t xfer = 0;" << endl << indent() << "std::string fname;" << endl << indent() << "::apache::thrift::protocol::TType ftype;" << endl @@ -1400,7 +1400,7 @@ void t_cpp_generator::generate_struct_writer(ofstream& out, t_struct* tstruct, b out << indent() << "uint32_t xfer = 0;" << endl; - indent(out) << "apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot);" << endl; + indent(out) << "::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot);" << endl; indent(out) << "xfer += oprot->writeStructBegin(\"" << name << "\");" << endl; for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { @@ -1707,7 +1707,7 @@ void t_cpp_generator::generate_service(t_service* tservice) { << endl; if (gen_cob_style_) { f_header_ << "#include <thrift/transport/TBufferTransports.h>" << endl << // TMemoryBuffer - "#include <thrift/cxxfunctional.h>" << endl + "#include <thrift/stdcxx.h>" << endl << "namespace apache { namespace thrift { namespace async {" << endl << "class TAsyncChannel;" << endl << "}}}" << endl; } @@ -1949,7 +1949,7 @@ void t_cpp_generator::generate_service_interface_factory(t_service* tservice, st f_header_ << "class " << singleton_factory_name << " : virtual public " << factory_name << " {" << endl << " public:" << endl; indent_up(); - f_header_ << indent() << singleton_factory_name << "(const boost::shared_ptr<" << service_if_name + f_header_ << indent() << singleton_factory_name << "(const ::apache::thrift::stdcxx::shared_ptr<" << service_if_name << ">& iface) : iface_(iface) {}" << endl << indent() << "virtual ~" << singleton_factory_name << "() {}" << endl << endl << indent() << "virtual " << service_if_name << "* getHandler(" @@ -1957,7 +1957,7 @@ void t_cpp_generator::generate_service_interface_factory(t_service* tservice, st << " return iface_.get();" << endl << indent() << "}" << endl << indent() << "virtual void releaseHandler(" << base_if_name << "* /* handler */) {}" << endl; - f_header_ << endl << " protected:" << endl << indent() << "boost::shared_ptr<" << service_if_name + f_header_ << endl << " protected:" << endl << indent() << "::apache::thrift::stdcxx::shared_ptr<" << service_if_name << "> iface_;" << endl; indent_down(); @@ -2065,8 +2065,7 @@ void t_cpp_generator::generate_service_async_skeleton(t_service* tservice) { << "using namespace ::apache::thrift;" << endl << "using namespace ::apache::thrift::protocol;" << endl << "using namespace ::apache::thrift::transport;" << endl - << "using namespace ::apache::thrift::async;" << endl << endl - << "using boost::shared_ptr;" << endl << endl; + << "using namespace ::apache::thrift::async;" << endl << endl; // the following code would not compile: // using namespace ; @@ -2128,7 +2127,7 @@ void t_cpp_generator::generate_service_multiface(t_service* tservice) { extends_multiface = ", public " + extends + "Multiface"; } - string list_type = string("std::vector<boost::shared_ptr<") + service_name_ + "If> >"; + string list_type = string("std::vector<apache::thrift::stdcxx::shared_ptr<") + service_name_ + "If> >"; // Generate the header portion f_header_ << "class " << service_name_ << "Multiface : " @@ -2139,7 +2138,7 @@ void t_cpp_generator::generate_service_multiface(t_service* tservice) { << "& ifaces) : ifaces_(ifaces) {" << endl; if (!extends.empty()) { f_header_ << indent() - << " std::vector<boost::shared_ptr<" + service_name_ + "If> >::iterator iter;" + << " std::vector<apache::thrift::stdcxx::shared_ptr<" + service_name_ + "If> >::iterator iter;" << endl << indent() << " for (iter = ifaces.begin(); iter != ifaces.end(); ++iter) {" << endl << indent() << " " << extends << "Multiface::add(*iter);" << endl << indent() << " }" << endl; @@ -2152,7 +2151,7 @@ void t_cpp_generator::generate_service_multiface(t_service* tservice) { f_header_ << " protected:" << endl; indent_up(); f_header_ << indent() << list_type << " ifaces_;" << endl << indent() << service_name_ - << "Multiface() {}" << endl << indent() << "void add(boost::shared_ptr<" + << "Multiface() {}" << endl << indent() << "void add(::apache::thrift::stdcxx::shared_ptr<" << service_name_ << "If> iface) {" << endl; if (!extends.empty()) { f_header_ << indent() << " " << extends << "Multiface::add(iface);" << endl; @@ -2234,7 +2233,7 @@ void t_cpp_generator::generate_service_client(t_service* tservice, string style) } else { protocol_type = "::apache::thrift::protocol::TProtocol"; } - string prot_ptr = "boost::shared_ptr< " + protocol_type + ">"; + string prot_ptr = "apache::thrift::stdcxx::shared_ptr< " + protocol_type + ">"; string client_suffix = "Client" + template_suffix; string if_suffix = "If"; if (style == "Cob") { @@ -2311,18 +2310,18 @@ void t_cpp_generator::generate_service_client(t_service* tservice, string style) // Note that these are not currently templated for simplicity. // TODO(simpkins): should they be templated? f_header_ << indent() - << "boost::shared_ptr< ::apache::thrift::protocol::TProtocol> getInputProtocol() {" + << "apache::thrift::stdcxx::shared_ptr< ::apache::thrift::protocol::TProtocol> getInputProtocol() {" << endl << indent() << " return " << _this << "piprot_;" << endl << indent() << "}" << endl; f_header_ << indent() - << "boost::shared_ptr< ::apache::thrift::protocol::TProtocol> getOutputProtocol() {" + << "apache::thrift::stdcxx::shared_ptr< ::apache::thrift::protocol::TProtocol> getOutputProtocol() {" << endl << indent() << " return " << _this << "poprot_;" << endl << indent() << "}" << endl; } else /* if (style == "Cob") */ { f_header_ << indent() << service_name_ << style << "Client" << short_suffix << "(" - << "boost::shared_ptr< ::apache::thrift::async::TAsyncChannel> channel, " + << "apache::thrift::stdcxx::shared_ptr< ::apache::thrift::async::TAsyncChannel> channel, " << "::apache::thrift::protocol::TProtocolFactory* protocolFactory) :" << endl; if (extends.empty()) { f_header_ << indent() << " channel_(channel)," << endl << indent() @@ -2332,9 +2331,9 @@ void t_cpp_generator::generate_service_client(t_service* tservice, string style) if (gen_templates_) { // TProtocolFactory classes return generic TProtocol pointers. // We have to dynamic cast to the Protocol_ type we are expecting. - f_header_ << indent() << " piprot_(boost::dynamic_pointer_cast<Protocol_>(" + f_header_ << indent() << " piprot_(::apache::thrift::stdcxx::dynamic_pointer_cast<Protocol_>(" << "protocolFactory->getProtocol(itrans_)))," << endl << indent() - << " poprot_(boost::dynamic_pointer_cast<Protocol_>(" + << " poprot_(::apache::thrift::stdcxx::dynamic_pointer_cast<Protocol_>(" << "protocolFactory->getProtocol(otrans_))) {" << endl; // Throw a TException if either dynamic cast failed. f_header_ << indent() << " if (!piprot_ || !poprot_) {" << endl << indent() @@ -2356,7 +2355,7 @@ void t_cpp_generator::generate_service_client(t_service* tservice, string style) if (style == "Cob") { f_header_ << indent() - << "boost::shared_ptr< ::apache::thrift::async::TAsyncChannel> getChannel() {" << endl + << "::apache::thrift::stdcxx::shared_ptr< ::apache::thrift::async::TAsyncChannel> getChannel() {" << endl << indent() << " return " << _this << "channel_;" << endl << indent() << "}" << endl; if (!gen_no_client_completion_) { f_header_ << indent() << "virtual void completed__(bool /* success */) {}" << endl; @@ -2408,11 +2407,11 @@ void t_cpp_generator::generate_service_client(t_service* tservice, string style) if (style == "Cob") { f_header_ << indent() - << "boost::shared_ptr< ::apache::thrift::async::TAsyncChannel> channel_;" << endl + << "::apache::thrift::stdcxx::shared_ptr< ::apache::thrift::async::TAsyncChannel> channel_;" << endl << indent() - << "boost::shared_ptr< ::apache::thrift::transport::TMemoryBuffer> itrans_;" << endl + << "::apache::thrift::stdcxx::shared_ptr< ::apache::thrift::transport::TMemoryBuffer> itrans_;" << endl << indent() - << "boost::shared_ptr< ::apache::thrift::transport::TMemoryBuffer> otrans_;" + << "::apache::thrift::stdcxx::shared_ptr< ::apache::thrift::transport::TMemoryBuffer> otrans_;" << endl; } f_header_ << @@ -2494,11 +2493,11 @@ void t_cpp_generator::generate_service_client(t_service* tservice, string style) } else { if (!(*f_iter)->is_oneway()) { out << indent() << _this << "channel_->sendAndRecvMessage(" - << "tcxx::bind(cob, this), " << _this << "otrans_.get(), " << _this << "itrans_.get());" + << "::apache::thrift::stdcxx::bind(cob, this), " << _this << "otrans_.get(), " << _this << "itrans_.get());" << endl; } else { out << indent() << _this << "channel_->sendMessage(" - << "tcxx::bind(cob, this), " << _this << "otrans_.get());" << endl; + << "::apache::thrift::stdcxx::bind(cob, this), " << _this << "otrans_.get());" << endl; } } scope_down(out); @@ -2849,8 +2848,8 @@ ProcessorGenerator::ProcessorGenerator(t_cpp_generator* generator, class_name_ = service_name_ + pstyle_ + "Processor"; if_name_ = service_name_ + "CobSvIf"; - finish_cob_ = "tcxx::function<void(bool ok)> cob, "; - finish_cob_decl_ = "tcxx::function<void(bool ok)>, "; + finish_cob_ = "::apache::thrift::stdcxx::function<void(bool ok)> cob, "; + finish_cob_decl_ = "::apache::thrift::stdcxx::function<void(bool ok)>, "; cob_arg_ = "cob, "; ret_type_ = "void "; } else { @@ -2911,7 +2910,7 @@ void ProcessorGenerator::generate_class_definition() { // Protected data members f_header_ << " protected:" << endl; indent_up(); - f_header_ << indent() << "boost::shared_ptr<" << if_name_ << "> iface_;" << endl; + f_header_ << indent() << "::apache::thrift::stdcxx::shared_ptr<" << if_name_ << "> iface_;" << endl; f_header_ << indent() << "virtual " << ret_type_ << "dispatchCall(" << finish_cob_ << "::apache::thrift::protocol::TProtocol* iprot, " << "::apache::thrift::protocol::TProtocol* oprot, " @@ -2967,29 +2966,29 @@ void ProcessorGenerator::generate_class_definition() { ? "" : ", const " + type_name((*f_iter)->get_returntype()) + "& _return"); f_header_ << indent() << "void return_" << (*f_iter)->get_name() - << "(tcxx::function<void(bool ok)> cob, int32_t seqid, " + << "(::apache::thrift::stdcxx::function<void(bool ok)> cob, int32_t seqid, " << "::apache::thrift::protocol::TProtocol* oprot, " << "void* ctx" << ret_arg << ");" << endl; if (generator_->gen_templates_) { f_header_ << indent() << "void return_" << (*f_iter)->get_name() - << "(tcxx::function<void(bool ok)> cob, int32_t seqid, " + << "(::apache::thrift::stdcxx::function<void(bool ok)> cob, int32_t seqid, " << "Protocol_* oprot, void* ctx" << ret_arg << ");" << endl; } // XXX Don't declare throw if it doesn't exist f_header_ << indent() << "void throw_" << (*f_iter)->get_name() - << "(tcxx::function<void(bool ok)> cob, int32_t seqid, " + << "(::apache::thrift::stdcxx::function<void(bool ok)> cob, int32_t seqid, " << "::apache::thrift::protocol::TProtocol* oprot, void* ctx, " << "::apache::thrift::TDelayedException* _throw);" << endl; if (generator_->gen_templates_) { f_header_ << indent() << "void throw_" << (*f_iter)->get_name() - << "(tcxx::function<void(bool ok)> cob, int32_t seqid, " + << "(::apache::thrift::stdcxx::function<void(bool ok)> cob, int32_t seqid, " << "Protocol_* oprot, void* ctx, " << "::apache::thrift::TDelayedException* _throw);" << endl; } } } - f_header_ << " public:" << endl << indent() << class_name_ << "(boost::shared_ptr<" << if_name_ + f_header_ << " public:" << endl << indent() << class_name_ << "(::apache::thrift::stdcxx::shared_ptr<" << if_name_ << "> iface) :" << endl; if (!extends_.empty()) { f_header_ << indent() << " " << extends_ << "(iface)," << endl; @@ -3127,14 +3126,14 @@ void ProcessorGenerator::generate_factory() { << endl << " public:" << endl; indent_up(); - f_header_ << indent() << factory_class_name_ << "(const ::boost::shared_ptr< " << if_factory_name + f_header_ << indent() << factory_class_name_ << "(const ::apache::thrift::stdcxx::shared_ptr< " << if_factory_name << " >& handlerFactory) :" << endl << indent() << " handlerFactory_(handlerFactory) {}" << endl << endl << indent() - << "::boost::shared_ptr< ::apache::thrift::" + << "::apache::thrift::stdcxx::shared_ptr< ::apache::thrift::" << (style_ == "Cob" ? "async::TAsyncProcessor" : "TProcessor") << " > " << "getProcessor(const ::apache::thrift::TConnectionInfo& connInfo);" << endl; - f_header_ << endl << " protected:" << endl << indent() << "::boost::shared_ptr< " + f_header_ << endl << " protected:" << endl << indent() << "::apache::thrift::stdcxx::shared_ptr< " << if_factory_name << " > handlerFactory_;" << endl; indent_down(); @@ -3149,17 +3148,17 @@ void ProcessorGenerator::generate_factory() { } // Generate the getProcessor() method - f_out_ << template_header_ << indent() << "::boost::shared_ptr< ::apache::thrift::" + f_out_ << template_header_ << indent() << "::apache::thrift::stdcxx::shared_ptr< ::apache::thrift::" << (style_ == "Cob" ? "async::TAsyncProcessor" : "TProcessor") << " > " << factory_class_name_ << template_suffix_ << "::getProcessor(" << "const ::apache::thrift::TConnectionInfo& connInfo) {" << endl; indent_up(); f_out_ << indent() << "::apache::thrift::ReleaseHandler< " << if_factory_name - << " > cleanup(handlerFactory_);" << endl << indent() << "::boost::shared_ptr< " + << " > cleanup(handlerFactory_);" << endl << indent() << "::apache::thrift::stdcxx::shared_ptr< " << if_name_ << " > handler(" << "handlerFactory_->getHandler(connInfo), cleanup);" << endl << indent() - << "::boost::shared_ptr< ::apache::thrift::" + << "::apache::thrift::stdcxx::shared_ptr< ::apache::thrift::" << (style_ == "Cob" ? "async::TAsyncProcessor" : "TProcessor") << " > " << "processor(new " << class_name_ << template_suffix_ << "(handler));" << endl << indent() << "return processor;" << endl; @@ -3394,7 +3393,7 @@ void t_cpp_generator::generate_process_function(t_service* tservice, out << indent() << "template <class Protocol_>" << endl; } out << "void " << tservice->get_name() << "AsyncProcessor" << class_suffix << "::process_" - << tfunction->get_name() << "(tcxx::function<void(bool ok)> cob, int32_t seqid, " + << tfunction->get_name() << "(::apache::thrift::stdcxx::function<void(bool ok)> cob, int32_t seqid, " << prot_type << "* iprot, " << prot_type << "* oprot)" << endl; scope_up(out); @@ -3451,28 +3450,28 @@ void t_cpp_generator::generate_process_function(t_service* tservice, // No return. Just hand off our cob. // TODO(dreiss): Call the cob immediately? out << indent() << "iface_->" << tfunction->get_name() << "(" - << "tcxx::bind(cob, true)" << endl; + << "::apache::thrift::stdcxx::bind(cob, true)" << endl; indent_up(); indent_up(); } else { string ret_arg, ret_placeholder; if (!tfunction->get_returntype()->is_void()) { ret_arg = ", const " + type_name(tfunction->get_returntype()) + "& _return"; - ret_placeholder = ", tcxx::placeholders::_1"; + ret_placeholder = ", ::apache::thrift::stdcxx::placeholders::_1"; } // When gen_templates_ is true, the return_ and throw_ functions are // overloaded. We have to declare pointers to them so that the compiler // can resolve the correct overloaded version. out << indent() << "void (" << tservice->get_name() << "AsyncProcessor" << class_suffix - << "::*return_fn)(tcxx::function<void(bool ok)> " + << "::*return_fn)(::apache::thrift::stdcxx::function<void(bool ok)> " << "cob, int32_t seqid, " << prot_type << "* oprot, void* ctx" << ret_arg << ") =" << endl; out << indent() << " &" << tservice->get_name() << "AsyncProcessor" << class_suffix << "::return_" << tfunction->get_name() << ";" << endl; if (!xceptions.empty()) { out << indent() << "void (" << tservice->get_name() << "AsyncProcessor" << class_suffix - << "::*throw_fn)(tcxx::function<void(bool ok)> " + << "::*throw_fn)(::apache::thrift::stdcxx::function<void(bool ok)> " << "cob, int32_t seqid, " << prot_type << "* oprot, void* ctx, " << "::apache::thrift::TDelayedException* _throw) =" << endl; out << indent() << " &" << tservice->get_name() << "AsyncProcessor" << class_suffix @@ -3482,11 +3481,11 @@ void t_cpp_generator::generate_process_function(t_service* tservice, out << indent() << "iface_->" << tfunction->get_name() << "(" << endl; indent_up(); indent_up(); - out << indent() << "tcxx::bind(return_fn, this, cob, seqid, oprot, ctx" << ret_placeholder + out << indent() << "::apache::thrift::stdcxx::bind(return_fn, this, cob, seqid, oprot, ctx" << ret_placeholder << ")"; if (!xceptions.empty()) { - out << ',' << endl << indent() << "tcxx::bind(throw_fn, this, cob, seqid, oprot, " - << "ctx, tcxx::placeholders::_1)"; + out << ',' << endl << indent() << "::apache::thrift::stdcxx::bind(throw_fn, this, cob, seqid, oprot, " + << "ctx, ::apache::thrift::stdcxx::placeholders::_1)"; } } @@ -3511,7 +3510,7 @@ void t_cpp_generator::generate_process_function(t_service* tservice, out << indent() << "template <class Protocol_>" << endl; } out << "void " << tservice->get_name() << "AsyncProcessor" << class_suffix << "::return_" - << tfunction->get_name() << "(tcxx::function<void(bool ok)> cob, int32_t seqid, " + << tfunction->get_name() << "(::apache::thrift::stdcxx::function<void(bool ok)> cob, int32_t seqid, " << prot_type << "* oprot, void* ctx" << ret_arg_decl << ')' << endl; scope_up(out); @@ -3559,7 +3558,7 @@ void t_cpp_generator::generate_process_function(t_service* tservice, out << indent() << "template <class Protocol_>" << endl; } out << "void " << tservice->get_name() << "AsyncProcessor" << class_suffix << "::throw_" - << tfunction->get_name() << "(tcxx::function<void(bool ok)> cob, int32_t seqid, " + << tfunction->get_name() << "(::apache::thrift::stdcxx::function<void(bool ok)> cob, int32_t seqid, " << prot_type << "* oprot, void* ctx, " << "::apache::thrift::TDelayedException* _throw)" << endl; scope_up(out); @@ -3659,8 +3658,7 @@ void t_cpp_generator::generate_service_skeleton(t_service* tservice) { << "using namespace ::apache::thrift;" << endl << "using namespace ::apache::thrift::protocol;" << endl << "using namespace ::apache::thrift::transport;" << endl - << "using namespace ::apache::thrift::server;" << endl << endl - << "using boost::shared_ptr;" << endl << endl; + << "using namespace ::apache::thrift::server;" << endl << endl; // the following code would not compile: // using namespace ; @@ -3690,13 +3688,13 @@ void t_cpp_generator::generate_service_skeleton(t_service* tservice) { f_skeleton << indent() << "int main(int argc, char **argv) {" << endl; indent_up(); f_skeleton - << indent() << "int port = 9090;" << endl << indent() << "shared_ptr<" << svcname + << indent() << "int port = 9090;" << endl << indent() << "::apache::thrift::stdcxx::shared_ptr<" << svcname << "Handler> handler(new " << svcname << "Handler());" << endl << indent() - << "shared_ptr<TProcessor> processor(new " << svcname << "Processor(handler));" << endl - << indent() << "shared_ptr<TServerTransport> serverTransport(new TServerSocket(port));" + << "::apache::thrift::stdcxx::shared_ptr<TProcessor> processor(new " << svcname << "Processor(handler));" << endl + << indent() << "::apache::thrift::stdcxx::shared_ptr<TServerTransport> serverTransport(new TServerSocket(port));" << endl << indent() - << "shared_ptr<TTransportFactory> transportFactory(new TBufferedTransportFactory());" << endl - << indent() << "shared_ptr<TProtocolFactory> protocolFactory(new TBinaryProtocolFactory());" + << "::apache::thrift::stdcxx::shared_ptr<TTransportFactory> transportFactory(new TBufferedTransportFactory());" << endl + << indent() << "::apache::thrift::stdcxx::shared_ptr<TProtocolFactory> protocolFactory(new TBinaryProtocolFactory());" << endl << endl << indent() << "TSimpleServer server(processor, serverTransport, transportFactory, protocolFactory);" << endl << indent() << "server.serve();" << endl << indent() << "return 0;" << endl; @@ -3785,7 +3783,7 @@ void t_cpp_generator::generate_deserialize_struct(ofstream& out, bool pointer) { if (pointer) { indent(out) << "if (!" << prefix << ") { " << endl; - indent(out) << " " << prefix << " = boost::shared_ptr<" << type_name(tstruct) << ">(new " + indent(out) << " " << prefix << " = ::apache::thrift::stdcxx::shared_ptr<" << type_name(tstruct) << ">(new " << type_name(tstruct) << ");" << endl; indent(out) << "}" << endl; indent(out) << "xfer += " << prefix << "->read(iprot);" << endl; @@ -4277,7 +4275,7 @@ string t_cpp_generator::declare_field(t_field* tfield, } result += type_name(tfield->get_type()); if (is_reference(tfield)) { - result = "boost::shared_ptr<" + result + ">"; + result = "::apache::thrift::stdcxx::shared_ptr<" + result + ">"; } if (pointer) { result += "*"; @@ -4356,13 +4354,13 @@ string t_cpp_generator::function_signature(t_function* tfunction, cob_type = (ttype->is_void() ? "()" : ("(" + type_name(ttype) + " const& _return)")); if (has_xceptions) { exn_cob - = ", tcxx::function<void(::apache::thrift::TDelayedException* _throw)> /* exn_cob */"; + = ", ::apache::thrift::stdcxx::function<void(::apache::thrift::TDelayedException* _throw)> /* exn_cob */"; } } else { throw "UNKNOWN STYLE"; } - return "void " + prefix + tfunction->get_name() + "(tcxx::function<void" + cob_type + "> cob" + return "void " + prefix + tfunction->get_name() + "(::apache::thrift::stdcxx::function<void" + cob_type + "> cob" + exn_cob + argument_list(arglist, name_params, true) + ")"; } else { throw "UNKNOWN STYLE"; http://git-wip-us.apache.org/repos/asf/thrift/blob/82ae9575/compiler/cpp/src/thrift/plugin/plugin.cc ---------------------------------------------------------------------- diff --git a/compiler/cpp/src/thrift/plugin/plugin.cc b/compiler/cpp/src/thrift/plugin/plugin.cc index 1d45d89..0bac135 100644 --- a/compiler/cpp/src/thrift/plugin/plugin.cc +++ b/compiler/cpp/src/thrift/plugin/plugin.cc @@ -27,17 +27,15 @@ #include <cassert> #include <iostream> -#include <boost/bind.hpp> #include <boost/range/adaptor/map.hpp> #include <boost/range/algorithm/for_each.hpp> -#include <boost/smart_ptr.hpp> #include "thrift/generate/t_generator.h" #include "thrift/plugin/type_util.h" #include "thrift/protocol/TBinaryProtocol.h" #include "thrift/transport/TBufferTransports.h" #include "thrift/transport/TFDTransport.h" - +#include "thrift/stdcxx.h" #include "thrift/plugin/plugin_types.h" namespace apache { @@ -121,7 +119,7 @@ struct TypeCache { void compileAll() { boost::for_each(*source | boost::adaptors::map_keys, - boost::bind(&TypeCache::compile, this, _1)); + stdcxx::bind(&TypeCache::compile, this, stdcxx::placeholders::_1)); } std::map<int64_t, S> const* source; @@ -218,7 +216,7 @@ THRIFT_CONVERSION(t_enum, g_program_cache[from.metadata.program_id]) { assert(to); THRIFT_ASSIGN_METADATA(); boost::for_each(from.constants | boost::adaptors::transformed(convert<t_enum_value>), - boost::bind(&::t_enum::append, to, _1)); + stdcxx::bind(&::t_enum::append, to, stdcxx::placeholders::_1)); } THRIFT_CONVERSION(t_list, resolve_type< ::t_type>(from.elem_type)) { assert(to); @@ -255,7 +253,7 @@ THRIFT_CONVERSION(t_const_value, ) { } else if (from.__isset.list_val) { to->set_list(); boost::for_each(from.list_val | boost::adaptors::transformed(&convert<t_const_value>), - boost::bind(&::t_const_value::add_list, to, _1)); + stdcxx::bind(&::t_const_value::add_list, to, stdcxx::placeholders::_1)); } else T_CONST_VALUE_CASE(string); else T_CONST_VALUE_CASE(integer); @@ -282,7 +280,7 @@ THRIFT_CONVERSION(t_struct, g_program_cache[from.metadata.program_id]) { to->set_union(from.is_union); to->set_xception(from.is_xception); boost::for_each(from.members | boost::adaptors::transformed(convert<t_field>), - boost::bind(&::t_struct::append, to, _1)); + stdcxx::bind(&::t_struct::append, to, stdcxx::placeholders::_1)); } THRIFT_CONVERSION(t_const, resolve_type< ::t_type>(from.type), @@ -309,7 +307,7 @@ THRIFT_CONVERSION(t_service, g_program_cache[from.metadata.program_id]) { THRIFT_ASSIGN_METADATA(); boost::for_each(from.functions | boost::adaptors::transformed(convert<t_function>), - boost::bind(&::t_service::add_function, to, _1)); + stdcxx::bind(&::t_service::add_function, to, stdcxx::placeholders::_1)); if (from.__isset.extends_) to->set_extends(resolve_service(from.extends_)); @@ -390,9 +388,9 @@ THRIFT_CONVERT_COMPLETE(t_program) { to->set_out_path(from.out_path, from.out_path_is_absolute); boost::for_each(from.typedefs | boost::adaptors::transformed(&resolve_type< ::t_typedef>), - boost::bind(&::t_program::add_typedef, to, _1)); + stdcxx::bind(&::t_program::add_typedef, to, stdcxx::placeholders::_1)); boost::for_each(from.enums | boost::adaptors::transformed(&resolve_type< ::t_enum>), - boost::bind(&::t_program::add_enum, to, _1)); + stdcxx::bind(&::t_program::add_enum, to, stdcxx::placeholders::_1)); for (std::vector<int64_t>::const_iterator it = from.objects.begin(); it != from.objects.end(); it++) { ::t_struct* t2 = resolve_type< ::t_struct>(*it); @@ -403,18 +401,18 @@ THRIFT_CONVERT_COMPLETE(t_program) { } } boost::for_each(from.consts | boost::adaptors::transformed(&resolve_const), - boost::bind(&::t_program::add_const, to, _1)); + stdcxx::bind(&::t_program::add_const, to, stdcxx::placeholders::_1)); boost::for_each(from.services | boost::adaptors::transformed(&resolve_service), - boost::bind(&::t_program::add_service, to, _1)); + stdcxx::bind(&::t_program::add_service, to, stdcxx::placeholders::_1)); for (std::vector<t_program>::const_iterator it = from.includes.begin(); it != from.includes.end(); it++) { convert(*it, g_program_cache[it->program_id]); } std::for_each(from.c_includes.begin(), from.c_includes.end(), - boost::bind(&::t_program::add_c_include, to, _1)); + stdcxx::bind(&::t_program::add_c_include, to, stdcxx::placeholders::_1)); std::for_each(from.cpp_includes.begin(), from.cpp_includes.end(), - boost::bind(&::t_program::add_cpp_include, to, _1)); + stdcxx::bind(&::t_program::add_cpp_include, to, stdcxx::placeholders::_1)); for (std::map<std::string, std::string>::const_iterator it = from.namespaces.begin(); it != from.namespaces.end(); it++) { to->set_namespace(it->first, it->second); @@ -428,8 +426,8 @@ int GeneratorPlugin::exec(int, char* []) { #ifdef _WIN32 _setmode(fileno(stdin), _O_BINARY); #endif - boost::shared_ptr<TFramedTransport> transport( - new TFramedTransport(boost::make_shared<TFDTransport>(fileno(stdin)))); + stdcxx::shared_ptr<TFramedTransport> transport( + new TFramedTransport(stdcxx::make_shared<TFDTransport>(fileno(stdin)))); TBinaryProtocol proto(transport); GeneratorInput input; try { http://git-wip-us.apache.org/repos/asf/thrift/blob/82ae9575/compiler/cpp/src/thrift/plugin/plugin_output.cc ---------------------------------------------------------------------- diff --git a/compiler/cpp/src/thrift/plugin/plugin_output.cc b/compiler/cpp/src/thrift/plugin/plugin_output.cc index 168a4a6..75725a1 100644 --- a/compiler/cpp/src/thrift/plugin/plugin_output.cc +++ b/compiler/cpp/src/thrift/plugin/plugin_output.cc @@ -34,12 +34,12 @@ #include <boost/range/adaptor/map.hpp> #include <boost/range/algorithm/copy.hpp> #include <boost/range/algorithm/transform.hpp> -#include <boost/smart_ptr.hpp> #include "thrift/generate/t_generator.h" #include "thrift/plugin/plugin.h" #include "thrift/plugin/type_util.h" #include "thrift/protocol/TBinaryProtocol.h" +#include "thrift/stdcxx.h" #include "thrift/transport/TBufferTransports.h" #include "thrift/transport/TFDTransport.h" @@ -55,6 +55,8 @@ typename apache::thrift::plugin::ToType<From>::type convert(From* from) { } using apache::thrift::protocol::TBinaryProtocol; +using apache::thrift::stdcxx::make_shared; +using apache::thrift::stdcxx::shared_ptr; using apache::thrift::transport::TFDTransport; using apache::thrift::transport::TFramedTransport; @@ -377,8 +379,8 @@ PluginDelegateResult delegateToPlugin(t_program* program, const std::string& opt #ifdef _WIN32 _setmode(fileno(fd), _O_BINARY); #endif - boost::shared_ptr<TFramedTransport> transport( - new TFramedTransport(boost::make_shared<TFDTransport>(fileno(fd)))); + shared_ptr<TFramedTransport> transport( + new TFramedTransport(make_shared<TFDTransport>(fileno(fd)))); TBinaryProtocol proto(transport); plugin::GeneratorInput input; http://git-wip-us.apache.org/repos/asf/thrift/blob/82ae9575/lib/c_glib/test/testthrifttestclient.cpp ---------------------------------------------------------------------- diff --git a/lib/c_glib/test/testthrifttestclient.cpp b/lib/c_glib/test/testthrifttestclient.cpp index 7681cf5..5b06883 100755 --- a/lib/c_glib/test/testthrifttestclient.cpp +++ b/lib/c_glib/test/testthrifttestclient.cpp @@ -17,7 +17,7 @@ * under the License. */ -/* test a C client with a C++ server */ +/* test a C client with a C++ server (that makes sense...) */ #include <signal.h> #include <sys/types.h> @@ -25,23 +25,34 @@ #include <thrift/protocol/TBinaryProtocol.h> #include <thrift/protocol/TDebugProtocol.h> #include <thrift/server/TSimpleServer.h> +#include <thrift/stdcxx.h> #include <thrift/transport/TServerSocket.h> #include "ThriftTest.h" #include "ThriftTest_types.h" #include <iostream> - -using namespace std; -using namespace boost; +#include <map> +#include <set> +#include <string> +#include <vector> using namespace apache::thrift; using namespace apache::thrift::concurrency; using namespace apache::thrift::protocol; -using namespace apache::thrift::transport; using namespace apache::thrift::server; +using namespace apache::thrift::transport; using namespace thrift::test; +using std::cout; +using std::endl; +using std::fixed; +using std::make_pair; +using std::map; +using std::set; +using std::string; +using std::vector; + #define TEST_PORT 9980 // Extra functions required for ThriftTest_types to work @@ -347,7 +358,7 @@ test_thrift_client (void) gchar *string = NULL; gint8 byte = 0; gint16 i16 = 0; - gint32 i32 = 0, another_i32 = 56789; + gint32 i32 = 0, another_i32 = 56789; gint64 i64 = 0; double dbl = 0.0; TTestXtruct *xtruct_in, *xtruct_out; @@ -356,7 +367,7 @@ test_thrift_client (void) GHashTable *set_in = NULL, *set_out = NULL; GArray *list_in = NULL, *list_out = NULL; TTestNumberz enum_in, enum_out; - TTestUserId user_id_in, user_id_out; + TTestUserId user_id_in, user_id_out; GHashTable *insanity_in = NULL; TTestXtruct *xtruct1, *xtruct2; TTestInsanity *insanity_out = NULL; @@ -371,7 +382,7 @@ test_thrift_client (void) #endif // create a C client - tsocket = (ThriftSocket *) g_object_new (THRIFT_TYPE_SOCKET, + tsocket = (ThriftSocket *) g_object_new (THRIFT_TYPE_SOCKET, "hostname", "localhost", "port", TEST_PORT, NULL); protocol = (ThriftBinaryProtocol *) g_object_new (THRIFT_TYPE_BINARY_PROTOCOL, @@ -607,11 +618,11 @@ main (void) if (pid == 0) /* child */ { - boost::shared_ptr<TProtocolFactory> protocolFactory(new TBinaryProtocolFactory()); - boost::shared_ptr<TestHandler> testHandler(new TestHandler()); - boost::shared_ptr<ThriftTestProcessor> testProcessor(new ThriftTestProcessor(testHandler)); - boost::shared_ptr<TServerSocket> serverSocket(new TServerSocket(TEST_PORT)); - boost::shared_ptr<TTransportFactory> transportFactory(new TBufferedTransportFactory()); + stdcxx::shared_ptr<TProtocolFactory> protocolFactory(new TBinaryProtocolFactory()); + stdcxx::shared_ptr<TestHandler> testHandler(new TestHandler()); + stdcxx::shared_ptr<ThriftTestProcessor> testProcessor(new ThriftTestProcessor(testHandler)); + stdcxx::shared_ptr<TServerSocket> serverSocket(new TServerSocket(TEST_PORT)); + stdcxx::shared_ptr<TTransportFactory> transportFactory(new TBufferedTransportFactory()); TSimpleServer simpleServer(testProcessor, serverSocket, transportFactory, protocolFactory); signal (SIGALRM, bailout); alarm (60); http://git-wip-us.apache.org/repos/asf/thrift/blob/82ae9575/lib/cpp/Makefile.am ---------------------------------------------------------------------- diff --git a/lib/cpp/Makefile.am b/lib/cpp/Makefile.am index 64cf98e..77d4d6c 100755 --- a/lib/cpp/Makefile.am +++ b/lib/cpp/Makefile.am @@ -122,7 +122,7 @@ libthriftnb_la_SOURCES = src/thrift/server/TNonblockingServer.cpp \ libthriftz_la_SOURCES = src/thrift/transport/TZlibTransport.cpp \ src/thrift/transport/THeaderTransport.cpp \ - src/thrift/protocol/THeaderProtocol.cpp + src/thrift/protocol/THeaderProtocol.cpp libthriftqt_la_MOC = src/thrift/qt/moc_TQTcpServer.cpp @@ -164,8 +164,8 @@ include_thrift_HEADERS = \ src/thrift/TProcessor.h \ src/thrift/TApplicationException.h \ src/thrift/TLogging.h \ - src/thrift/cxxfunctional.h \ src/thrift/TToString.h \ + src/thrift/stdcxx.h \ src/thrift/TBase.h include_concurrencydir = $(include_thriftdir)/concurrency http://git-wip-us.apache.org/repos/asf/thrift/blob/82ae9575/lib/cpp/README.md ---------------------------------------------------------------------- diff --git a/lib/cpp/README.md b/lib/cpp/README.md index a7f7e79..e744a6a 100755 --- a/lib/cpp/README.md +++ b/lib/cpp/README.md @@ -19,7 +19,6 @@ KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. - # Using Thrift with C++ The Thrift C++ libraries are built using the GNU tools. Follow the instructions @@ -55,15 +54,22 @@ you are using libthriftnb you will also need libevent. ## Dependencies -boost shared pointers -http://www.boost.org/libs/smart_ptr/smart_ptr.htm +If your C++ environment implements C++11 or later, thrift will automatically use +std::shared_ptr. Otherwise you will need the boost library to provide a shared_ptr +implementation for C++ environments pre-C++11. If you are linking against code +that expects to be using boost::shared_ptr, you can define the preprocessor +variable FORCE_BOOST_SMART_PTR for your build of thrift to make it use boost instead +of std for a number of memory related classes. See thrift/stdcxx.h for more. libevent (for libthriftnb only) http://monkey.org/~provos/libevent/ # Using Thrift with C++ on Windows -You need to define an environment variables for 3rd party components separately: +Both the autoconf and cmake build systems are able to automatically detect many +system configurations without the need to specify library locations, however if +you run into problems or want to redirect thrift to build and link against your +own provided third party libraries: BOOST_ROOT : For boost, e.g. D:\boost_1_55_0 OPENSSL_ROOT_DIR : For OpenSSL, e.g. D:\OpenSSL-Win32 @@ -74,13 +80,7 @@ LIBEVENT_ROOT_DIR : For Libevent e.g. D:\libevent-2.0.21-stable See /3rdparty.user for more details. -Thrift is divided into two libraries. - -* libthrift - The core Thrift library contains all the core Thrift code. It requires - boost shared pointers, pthreads, and librt. - -* libthriftnb - This library contains the Thrift nonblocking server, which uses libevent. - To link this library you will also need to link libevent. +The same linking guidelines described above for libthriftnb apply to windows as well. ## Linking Against Thrift @@ -93,8 +93,7 @@ the config header: "windows/confg.h" ## Dependencies -boost shared pointers -http://www.boost.org/libs/smart_ptr/smart_ptr.htm +The same dependencies for shared_ptr as described above apply to windows as well. boost thread http://www.boost.org/doc/libs/release/doc/html/thread.html @@ -277,6 +276,12 @@ overridden if it's not strong enough for you. ## 0.11.0 +Older versions of thrift depended on the <boost/smart_ptr.hpp> classes which +were used in thrift headers to define interfaces. Thrift now detects C++11 +at build time and will prefer to use <memory> classes from C++11 instead. +You can force the library to build with boost memory classes by defining the +preprocessor macro `FORCE_BOOST_SMART_PTR`. (THRIFT-2221) + In the pthread mutex implementation, the contention profiling code was enabled by default in all builds. This changed to be disabled by default. (THRIFT-4151) http://git-wip-us.apache.org/repos/asf/thrift/blob/82ae9575/lib/cpp/src/thrift/TDispatchProcessor.h ---------------------------------------------------------------------- diff --git a/lib/cpp/src/thrift/TDispatchProcessor.h b/lib/cpp/src/thrift/TDispatchProcessor.h index fd1dce7..dadc87b 100644 --- a/lib/cpp/src/thrift/TDispatchProcessor.h +++ b/lib/cpp/src/thrift/TDispatchProcessor.h @@ -33,8 +33,8 @@ namespace thrift { template <class Protocol_> class TDispatchProcessorT : public TProcessor { public: - virtual bool process(boost::shared_ptr<protocol::TProtocol> in, - boost::shared_ptr<protocol::TProtocol> out, + virtual bool process(stdcxx::shared_ptr<protocol::TProtocol> in, + stdcxx::shared_ptr<protocol::TProtocol> out, void* connectionContext) { protocol::TProtocol* inRaw = in.get(); protocol::TProtocol* outRaw = out.get(); @@ -105,8 +105,8 @@ protected: */ class TDispatchProcessor : public TProcessor { public: - virtual bool process(boost::shared_ptr<protocol::TProtocol> in, - boost::shared_ptr<protocol::TProtocol> out, + virtual bool process(stdcxx::shared_ptr<protocol::TProtocol> in, + stdcxx::shared_ptr<protocol::TProtocol> out, void* connectionContext) { std::string fname; protocol::TMessageType mtype; http://git-wip-us.apache.org/repos/asf/thrift/blob/82ae9575/lib/cpp/src/thrift/TProcessor.h ---------------------------------------------------------------------- diff --git a/lib/cpp/src/thrift/TProcessor.h b/lib/cpp/src/thrift/TProcessor.h index 4a0604e..27294d3 100644 --- a/lib/cpp/src/thrift/TProcessor.h +++ b/lib/cpp/src/thrift/TProcessor.h @@ -22,7 +22,7 @@ #include <string> #include <thrift/protocol/TProtocol.h> -#include <boost/shared_ptr.hpp> +#include <thrift/stdcxx.h> namespace apache { namespace thrift { @@ -142,28 +142,28 @@ class TProcessor { public: virtual ~TProcessor() {} - virtual bool process(boost::shared_ptr<protocol::TProtocol> in, - boost::shared_ptr<protocol::TProtocol> out, + virtual bool process(stdcxx::shared_ptr<protocol::TProtocol> in, + stdcxx::shared_ptr<protocol::TProtocol> out, void* connectionContext) = 0; - bool process(boost::shared_ptr<apache::thrift::protocol::TProtocol> io, void* connectionContext) { + bool process(stdcxx::shared_ptr<apache::thrift::protocol::TProtocol> io, void* connectionContext) { return process(io, io, connectionContext); } - boost::shared_ptr<TProcessorEventHandler> getEventHandler() const { return eventHandler_; } + stdcxx::shared_ptr<TProcessorEventHandler> getEventHandler() const { return eventHandler_; } - void setEventHandler(boost::shared_ptr<TProcessorEventHandler> eventHandler) { + void setEventHandler(stdcxx::shared_ptr<TProcessorEventHandler> eventHandler) { eventHandler_ = eventHandler; } protected: TProcessor() {} - boost::shared_ptr<TProcessorEventHandler> eventHandler_; + stdcxx::shared_ptr<TProcessorEventHandler> eventHandler_; }; /** - * This is a helper class to allow boost::shared_ptr to be used with handler + * This is a helper class to allow stdcxx::shared_ptr to be used with handler * pointers returned by the generated handler factories. * * The handler factory classes generated by the thrift compiler return raw @@ -177,7 +177,7 @@ protected: template <typename HandlerFactory_> class ReleaseHandler { public: - ReleaseHandler(const boost::shared_ptr<HandlerFactory_>& handlerFactory) + ReleaseHandler(const stdcxx::shared_ptr<HandlerFactory_>& handlerFactory) : handlerFactory_(handlerFactory) {} void operator()(typename HandlerFactory_::Handler* handler) { @@ -187,18 +187,18 @@ public: } private: - boost::shared_ptr<HandlerFactory_> handlerFactory_; + stdcxx::shared_ptr<HandlerFactory_> handlerFactory_; }; struct TConnectionInfo { // The input and output protocols - boost::shared_ptr<protocol::TProtocol> input; - boost::shared_ptr<protocol::TProtocol> output; + stdcxx::shared_ptr<protocol::TProtocol> input; + stdcxx::shared_ptr<protocol::TProtocol> output; // The underlying transport used for the connection // This is the transport that was returned by TServerTransport::accept(), // and it may be different than the transport pointed to by the input and // output protocols. - boost::shared_ptr<transport::TTransport> transport; + stdcxx::shared_ptr<transport::TTransport> transport; }; class TProcessorFactory { @@ -212,17 +212,17 @@ public: * accepted on. This generally means that this call does not need to be * thread safe, as it will always be invoked from a single thread. */ - virtual boost::shared_ptr<TProcessor> getProcessor(const TConnectionInfo& connInfo) = 0; + virtual stdcxx::shared_ptr<TProcessor> getProcessor(const TConnectionInfo& connInfo) = 0; }; class TSingletonProcessorFactory : public TProcessorFactory { public: - TSingletonProcessorFactory(boost::shared_ptr<TProcessor> processor) : processor_(processor) {} + TSingletonProcessorFactory(stdcxx::shared_ptr<TProcessor> processor) : processor_(processor) {} - boost::shared_ptr<TProcessor> getProcessor(const TConnectionInfo&) { return processor_; } + stdcxx::shared_ptr<TProcessor> getProcessor(const TConnectionInfo&) { return processor_; } private: - boost::shared_ptr<TProcessor> processor_; + stdcxx::shared_ptr<TProcessor> processor_; }; } } // apache::thrift http://git-wip-us.apache.org/repos/asf/thrift/blob/82ae9575/lib/cpp/src/thrift/async/TAsyncBufferProcessor.h ---------------------------------------------------------------------- diff --git a/lib/cpp/src/thrift/async/TAsyncBufferProcessor.h b/lib/cpp/src/thrift/async/TAsyncBufferProcessor.h index 3c957a6..0d56c78 100644 --- a/lib/cpp/src/thrift/async/TAsyncBufferProcessor.h +++ b/lib/cpp/src/thrift/async/TAsyncBufferProcessor.h @@ -20,9 +20,7 @@ #ifndef _THRIFT_TASYNC_BUFFER_PROCESSOR_H_ #define _THRIFT_TASYNC_BUFFER_PROCESSOR_H_ 1 -#include <thrift/cxxfunctional.h> -#include <boost/shared_ptr.hpp> - +#include <thrift/stdcxx.h> #include <thrift/transport/TBufferTransports.h> namespace apache { @@ -36,9 +34,9 @@ public: // forcefully close the connection (if applicable). // "in" and "out" should be TMemoryBuffer or similar, // not a wrapper around a socket. - virtual void process(apache::thrift::stdcxx::function<void(bool healthy)> _return, - boost::shared_ptr<apache::thrift::transport::TBufferBase> ibuf, - boost::shared_ptr<apache::thrift::transport::TBufferBase> obuf) = 0; + virtual void process(stdcxx::function<void(bool healthy)> _return, + stdcxx::shared_ptr<transport::TBufferBase> ibuf, + stdcxx::shared_ptr<transport::TBufferBase> obuf) = 0; virtual ~TAsyncBufferProcessor() {} }; } http://git-wip-us.apache.org/repos/asf/thrift/blob/82ae9575/lib/cpp/src/thrift/async/TAsyncChannel.cpp ---------------------------------------------------------------------- diff --git a/lib/cpp/src/thrift/async/TAsyncChannel.cpp b/lib/cpp/src/thrift/async/TAsyncChannel.cpp index 4716af2..c87659f 100644 --- a/lib/cpp/src/thrift/async/TAsyncChannel.cpp +++ b/lib/cpp/src/thrift/async/TAsyncChannel.cpp @@ -18,7 +18,7 @@ */ #include <thrift/async/TAsyncChannel.h> -#include <thrift/cxxfunctional.h> +#include <thrift/stdcxx.h> namespace apache { namespace thrift { http://git-wip-us.apache.org/repos/asf/thrift/blob/82ae9575/lib/cpp/src/thrift/async/TAsyncChannel.h ---------------------------------------------------------------------- diff --git a/lib/cpp/src/thrift/async/TAsyncChannel.h b/lib/cpp/src/thrift/async/TAsyncChannel.h index eb3ce2a..f8d2b03 100644 --- a/lib/cpp/src/thrift/async/TAsyncChannel.h +++ b/lib/cpp/src/thrift/async/TAsyncChannel.h @@ -20,7 +20,7 @@ #ifndef _THRIFT_ASYNC_TASYNCCHANNEL_H_ #define _THRIFT_ASYNC_TASYNCCHANNEL_H_ 1 -#include <thrift/cxxfunctional.h> +#include <thrift/stdcxx.h> #include <thrift/Thrift.h> namespace apache { http://git-wip-us.apache.org/repos/asf/thrift/blob/82ae9575/lib/cpp/src/thrift/async/TAsyncDispatchProcessor.h ---------------------------------------------------------------------- diff --git a/lib/cpp/src/thrift/async/TAsyncDispatchProcessor.h b/lib/cpp/src/thrift/async/TAsyncDispatchProcessor.h index e79c57d..a1450f0 100644 --- a/lib/cpp/src/thrift/async/TAsyncDispatchProcessor.h +++ b/lib/cpp/src/thrift/async/TAsyncDispatchProcessor.h @@ -35,8 +35,8 @@ template <class Protocol_> class TAsyncDispatchProcessorT : public TAsyncProcessor { public: virtual void process(apache::thrift::stdcxx::function<void(bool success)> _return, - boost::shared_ptr<protocol::TProtocol> in, - boost::shared_ptr<protocol::TProtocol> out) { + stdcxx::shared_ptr<protocol::TProtocol> in, + stdcxx::shared_ptr<protocol::TProtocol> out) { protocol::TProtocol* inRaw = in.get(); protocol::TProtocol* outRaw = out.get(); @@ -107,8 +107,8 @@ public: class TAsyncDispatchProcessor : public TAsyncProcessor { public: virtual void process(apache::thrift::stdcxx::function<void(bool success)> _return, - boost::shared_ptr<protocol::TProtocol> in, - boost::shared_ptr<protocol::TProtocol> out) { + stdcxx::shared_ptr<protocol::TProtocol> in, + stdcxx::shared_ptr<protocol::TProtocol> out) { protocol::TProtocol* inRaw = in.get(); protocol::TProtocol* outRaw = out.get(); http://git-wip-us.apache.org/repos/asf/thrift/blob/82ae9575/lib/cpp/src/thrift/async/TAsyncProcessor.h ---------------------------------------------------------------------- diff --git a/lib/cpp/src/thrift/async/TAsyncProcessor.h b/lib/cpp/src/thrift/async/TAsyncProcessor.h index 01a34c4..afc4ffa 100644 --- a/lib/cpp/src/thrift/async/TAsyncProcessor.h +++ b/lib/cpp/src/thrift/async/TAsyncProcessor.h @@ -20,9 +20,8 @@ #ifndef _THRIFT_TASYNCPROCESSOR_H_ #define _THRIFT_TASYNCPROCESSOR_H_ 1 -#include <thrift/cxxfunctional.h> -#include <boost/shared_ptr.hpp> #include <thrift/protocol/TProtocol.h> +#include <thrift/stdcxx.h> #include <thrift/TProcessor.h> namespace apache { @@ -38,25 +37,25 @@ class TAsyncProcessor { public: virtual ~TAsyncProcessor() {} - virtual void process(apache::thrift::stdcxx::function<void(bool success)> _return, - boost::shared_ptr<protocol::TProtocol> in, - boost::shared_ptr<protocol::TProtocol> out) = 0; + virtual void process(stdcxx::function<void(bool success)> _return, + stdcxx::shared_ptr<protocol::TProtocol> in, + stdcxx::shared_ptr<protocol::TProtocol> out) = 0; - void process(apache::thrift::stdcxx::function<void(bool success)> _return, - boost::shared_ptr<apache::thrift::protocol::TProtocol> io) { + void process(stdcxx::function<void(bool success)> _return, + stdcxx::shared_ptr<protocol::TProtocol> io) { return process(_return, io, io); } - boost::shared_ptr<TProcessorEventHandler> getEventHandler() const { return eventHandler_; } + stdcxx::shared_ptr<TProcessorEventHandler> getEventHandler() const { return eventHandler_; } - void setEventHandler(boost::shared_ptr<TProcessorEventHandler> eventHandler) { + void setEventHandler(stdcxx::shared_ptr<TProcessorEventHandler> eventHandler) { eventHandler_ = eventHandler; } protected: TAsyncProcessor() {} - boost::shared_ptr<TProcessorEventHandler> eventHandler_; + stdcxx::shared_ptr<TProcessorEventHandler> eventHandler_; }; class TAsyncProcessorFactory { @@ -70,16 +69,15 @@ public: * accepted on. This generally means that this call does not need to be * thread safe, as it will always be invoked from a single thread. */ - virtual boost::shared_ptr<TAsyncProcessor> getProcessor(const TConnectionInfo& connInfo) = 0; + virtual stdcxx::shared_ptr<TAsyncProcessor> getProcessor(const TConnectionInfo& connInfo) = 0; }; } } } // apache::thrift::async -// XXX I'm lazy for now namespace apache { namespace thrift { -using apache::thrift::async::TAsyncProcessor; + using apache::thrift::async::TAsyncProcessor; } } http://git-wip-us.apache.org/repos/asf/thrift/blob/82ae9575/lib/cpp/src/thrift/async/TAsyncProtocolProcessor.cpp ---------------------------------------------------------------------- diff --git a/lib/cpp/src/thrift/async/TAsyncProtocolProcessor.cpp b/lib/cpp/src/thrift/async/TAsyncProtocolProcessor.cpp index 5a4f347..b9ffb04 100644 --- a/lib/cpp/src/thrift/async/TAsyncProtocolProcessor.cpp +++ b/lib/cpp/src/thrift/async/TAsyncProtocolProcessor.cpp @@ -27,10 +27,10 @@ namespace thrift { namespace async { void TAsyncProtocolProcessor::process(apache::thrift::stdcxx::function<void(bool healthy)> _return, - boost::shared_ptr<TBufferBase> ibuf, - boost::shared_ptr<TBufferBase> obuf) { - boost::shared_ptr<TProtocol> iprot(pfact_->getProtocol(ibuf)); - boost::shared_ptr<TProtocol> oprot(pfact_->getProtocol(obuf)); + stdcxx::shared_ptr<TBufferBase> ibuf, + stdcxx::shared_ptr<TBufferBase> obuf) { + stdcxx::shared_ptr<TProtocol> iprot(pfact_->getProtocol(ibuf)); + stdcxx::shared_ptr<TProtocol> oprot(pfact_->getProtocol(obuf)); return underlying_ ->process(apache::thrift::stdcxx::bind(&TAsyncProtocolProcessor::finish, _return, @@ -42,7 +42,7 @@ void TAsyncProtocolProcessor::process(apache::thrift::stdcxx::function<void(bool /* static */ void TAsyncProtocolProcessor::finish( apache::thrift::stdcxx::function<void(bool healthy)> _return, - boost::shared_ptr<TProtocol> oprot, + stdcxx::shared_ptr<TProtocol> oprot, bool healthy) { (void)oprot; // This is a stub function to hold a reference to oprot. http://git-wip-us.apache.org/repos/asf/thrift/blob/82ae9575/lib/cpp/src/thrift/async/TAsyncProtocolProcessor.h ---------------------------------------------------------------------- diff --git a/lib/cpp/src/thrift/async/TAsyncProtocolProcessor.h b/lib/cpp/src/thrift/async/TAsyncProtocolProcessor.h index 3f2b394..ce3883c 100644 --- a/lib/cpp/src/thrift/async/TAsyncProtocolProcessor.h +++ b/lib/cpp/src/thrift/async/TAsyncProtocolProcessor.h @@ -30,23 +30,23 @@ namespace async { class TAsyncProtocolProcessor : public TAsyncBufferProcessor { public: - TAsyncProtocolProcessor(boost::shared_ptr<TAsyncProcessor> underlying, - boost::shared_ptr<apache::thrift::protocol::TProtocolFactory> pfact) + TAsyncProtocolProcessor(stdcxx::shared_ptr<TAsyncProcessor> underlying, + stdcxx::shared_ptr<apache::thrift::protocol::TProtocolFactory> pfact) : underlying_(underlying), pfact_(pfact) {} virtual void process(apache::thrift::stdcxx::function<void(bool healthy)> _return, - boost::shared_ptr<apache::thrift::transport::TBufferBase> ibuf, - boost::shared_ptr<apache::thrift::transport::TBufferBase> obuf); + stdcxx::shared_ptr<apache::thrift::transport::TBufferBase> ibuf, + stdcxx::shared_ptr<apache::thrift::transport::TBufferBase> obuf); virtual ~TAsyncProtocolProcessor() {} private: static void finish(apache::thrift::stdcxx::function<void(bool healthy)> _return, - boost::shared_ptr<apache::thrift::protocol::TProtocol> oprot, + stdcxx::shared_ptr<apache::thrift::protocol::TProtocol> oprot, bool healthy); - boost::shared_ptr<TAsyncProcessor> underlying_; - boost::shared_ptr<apache::thrift::protocol::TProtocolFactory> pfact_; + stdcxx::shared_ptr<TAsyncProcessor> underlying_; + stdcxx::shared_ptr<apache::thrift::protocol::TProtocolFactory> pfact_; }; } } http://git-wip-us.apache.org/repos/asf/thrift/blob/82ae9575/lib/cpp/src/thrift/async/TConcurrentClientSyncInfo.h ---------------------------------------------------------------------- diff --git a/lib/cpp/src/thrift/async/TConcurrentClientSyncInfo.h b/lib/cpp/src/thrift/async/TConcurrentClientSyncInfo.h index 7afcbc2..9ec77b9 100644 --- a/lib/cpp/src/thrift/async/TConcurrentClientSyncInfo.h +++ b/lib/cpp/src/thrift/async/TConcurrentClientSyncInfo.h @@ -22,7 +22,7 @@ #include <thrift/protocol/TProtocol.h> #include <thrift/concurrency/Mutex.h> #include <thrift/concurrency/Monitor.h> -#include <boost/shared_ptr.hpp> +#include <thrift/stdcxx.h> #include <vector> #include <string> #include <map> @@ -60,7 +60,7 @@ private: class TConcurrentClientSyncInfo { private: // typedefs - typedef boost::shared_ptr< ::apache::thrift::concurrency::Monitor> MonitorPtr; + typedef stdcxx::shared_ptr< ::apache::thrift::concurrency::Monitor> MonitorPtr; typedef std::map<int32_t, MonitorPtr> MonitorMap; public: http://git-wip-us.apache.org/repos/asf/thrift/blob/82ae9575/lib/cpp/src/thrift/async/TEvhttpClientChannel.h ---------------------------------------------------------------------- diff --git a/lib/cpp/src/thrift/async/TEvhttpClientChannel.h b/lib/cpp/src/thrift/async/TEvhttpClientChannel.h index 72eb32d..9774952 100644 --- a/lib/cpp/src/thrift/async/TEvhttpClientChannel.h +++ b/lib/cpp/src/thrift/async/TEvhttpClientChannel.h @@ -23,7 +23,7 @@ #include <queue> #include <string> #include <utility> -#include <boost/shared_ptr.hpp> +#include <thrift/stdcxx.h> #include <thrift/async/TAsyncChannel.h> struct event_base; http://git-wip-us.apache.org/repos/asf/thrift/blob/82ae9575/lib/cpp/src/thrift/async/TEvhttpServer.cpp ---------------------------------------------------------------------- diff --git a/lib/cpp/src/thrift/async/TEvhttpServer.cpp b/lib/cpp/src/thrift/async/TEvhttpServer.cpp index 4fa41f8..d87e507 100644 --- a/lib/cpp/src/thrift/async/TEvhttpServer.cpp +++ b/lib/cpp/src/thrift/async/TEvhttpServer.cpp @@ -20,7 +20,7 @@ #include <thrift/async/TEvhttpServer.h> #include <thrift/async/TAsyncBufferProcessor.h> #include <thrift/transport/TBufferTransports.h> -#include <boost/scoped_ptr.hpp> +#include <thrift/stdcxx.h> #include <evhttp.h> #include <event2/buffer.h> #include <event2/buffer_compat.h> @@ -31,6 +31,8 @@ #endif using apache::thrift::transport::TMemoryBuffer; +using apache::thrift::stdcxx::scoped_ptr; +using apache::thrift::stdcxx::shared_ptr; namespace apache { namespace thrift { @@ -38,17 +40,17 @@ namespace async { struct TEvhttpServer::RequestContext { struct evhttp_request* req; - boost::shared_ptr<apache::thrift::transport::TMemoryBuffer> ibuf; - boost::shared_ptr<apache::thrift::transport::TMemoryBuffer> obuf; + stdcxx::shared_ptr<apache::thrift::transport::TMemoryBuffer> ibuf; + stdcxx::shared_ptr<apache::thrift::transport::TMemoryBuffer> obuf; RequestContext(struct evhttp_request* req); }; -TEvhttpServer::TEvhttpServer(boost::shared_ptr<TAsyncBufferProcessor> processor) +TEvhttpServer::TEvhttpServer(stdcxx::shared_ptr<TAsyncBufferProcessor> processor) : processor_(processor), eb_(NULL), eh_(NULL) { } -TEvhttpServer::TEvhttpServer(boost::shared_ptr<TAsyncBufferProcessor> processor, int port) +TEvhttpServer::TEvhttpServer(stdcxx::shared_ptr<TAsyncBufferProcessor> processor, int port) : processor_(processor), eb_(NULL), eh_(NULL) { // Create event_base and evhttp. eb_ = event_base_new(); @@ -118,7 +120,7 @@ void TEvhttpServer::process(struct evhttp_request* req) { void TEvhttpServer::complete(RequestContext* ctx, bool success) { (void)success; - boost::scoped_ptr<RequestContext> ptr(ctx); + scoped_ptr<RequestContext> ptr(ctx); int code = success ? 200 : 400; const char* reason = success ? "OK" : "Bad Request"; http://git-wip-us.apache.org/repos/asf/thrift/blob/82ae9575/lib/cpp/src/thrift/async/TEvhttpServer.h ---------------------------------------------------------------------- diff --git a/lib/cpp/src/thrift/async/TEvhttpServer.h b/lib/cpp/src/thrift/async/TEvhttpServer.h index 89bf337..afc679c 100644 --- a/lib/cpp/src/thrift/async/TEvhttpServer.h +++ b/lib/cpp/src/thrift/async/TEvhttpServer.h @@ -20,7 +20,7 @@ #ifndef _THRIFT_TEVHTTP_SERVER_H_ #define _THRIFT_TEVHTTP_SERVER_H_ 1 -#include <boost/shared_ptr.hpp> +#include <thrift/stdcxx.h> struct event_base; struct evhttp; @@ -41,14 +41,14 @@ public: * address of the server as the extra arg. * Do not call "serve" on this server. */ - TEvhttpServer(boost::shared_ptr<TAsyncBufferProcessor> processor); + TEvhttpServer(stdcxx::shared_ptr<TAsyncBufferProcessor> processor); /** * Create a TEvhttpServer with an embedded event_base and evhttp, * listening on port and responding on the endpoint "/". * Call "serve" on this server to serve forever. */ - TEvhttpServer(boost::shared_ptr<TAsyncBufferProcessor> processor, int port); + TEvhttpServer(stdcxx::shared_ptr<TAsyncBufferProcessor> processor, int port); ~TEvhttpServer(); @@ -63,7 +63,7 @@ private: void process(struct evhttp_request* req); void complete(RequestContext* ctx, bool success); - boost::shared_ptr<TAsyncBufferProcessor> processor_; + stdcxx::shared_ptr<TAsyncBufferProcessor> processor_; struct event_base* eb_; struct evhttp* eh_; }; http://git-wip-us.apache.org/repos/asf/thrift/blob/82ae9575/lib/cpp/src/thrift/concurrency/BoostMonitor.cpp ---------------------------------------------------------------------- diff --git a/lib/cpp/src/thrift/concurrency/BoostMonitor.cpp b/lib/cpp/src/thrift/concurrency/BoostMonitor.cpp index 6c24d82..ebfa0b9 100644 --- a/lib/cpp/src/thrift/concurrency/BoostMonitor.cpp +++ b/lib/cpp/src/thrift/concurrency/BoostMonitor.cpp @@ -23,9 +23,9 @@ #include <thrift/concurrency/Exception.h> #include <thrift/concurrency/Util.h> #include <thrift/transport/PlatformSocket.h> -#include <assert.h> +#include <thrift/stdcxx.h> -#include <boost/scoped_ptr.hpp> +#include <assert.h> #include <boost/thread.hpp> #include <boost/date_time/posix_time/posix_time.hpp> @@ -155,7 +155,7 @@ public: private: void init(Mutex* mutex) { mutex_ = mutex; } - boost::scoped_ptr<Mutex> ownedMutex_; + stdcxx::scoped_ptr<Mutex> ownedMutex_; Mutex* mutex_; }; http://git-wip-us.apache.org/repos/asf/thrift/blob/82ae9575/lib/cpp/src/thrift/concurrency/BoostThreadFactory.cpp ---------------------------------------------------------------------- diff --git a/lib/cpp/src/thrift/concurrency/BoostThreadFactory.cpp b/lib/cpp/src/thrift/concurrency/BoostThreadFactory.cpp index 8afabf9..3661275 100644 --- a/lib/cpp/src/thrift/concurrency/BoostThreadFactory.cpp +++ b/lib/cpp/src/thrift/concurrency/BoostThreadFactory.cpp @@ -23,19 +23,20 @@ #include <thrift/concurrency/BoostThreadFactory.h> #include <thrift/concurrency/Exception.h> - +#include <thrift/stdcxx.h> #include <cassert> -#include <boost/scoped_ptr.hpp> #include <boost/thread.hpp> -#include <boost/weak_ptr.hpp> namespace apache { namespace thrift { -namespace concurrency { -using boost::shared_ptr; -using boost::weak_ptr; +using stdcxx::bind; +using stdcxx::scoped_ptr; +using stdcxx::shared_ptr; +using stdcxx::weak_ptr; + +namespace concurrency { /** * The boost thread class. @@ -49,7 +50,7 @@ public: static void* threadMain(void* arg); private: - boost::scoped_ptr<boost::thread> thread_; + scoped_ptr<boost::thread> thread_; STATE state_; weak_ptr<BoostThread> self_; bool detached_; @@ -81,7 +82,7 @@ public: state_ = starting; - thread_.reset(new boost::thread(boost::bind(threadMain, (void*)selfRef))); + thread_.reset(new boost::thread(bind(threadMain, (void*)selfRef))); if (detached_) thread_->detach(); http://git-wip-us.apache.org/repos/asf/thrift/blob/82ae9575/lib/cpp/src/thrift/concurrency/BoostThreadFactory.h ---------------------------------------------------------------------- diff --git a/lib/cpp/src/thrift/concurrency/BoostThreadFactory.h b/lib/cpp/src/thrift/concurrency/BoostThreadFactory.h index 7973245..4c7a45a 100644 --- a/lib/cpp/src/thrift/concurrency/BoostThreadFactory.h +++ b/lib/cpp/src/thrift/concurrency/BoostThreadFactory.h @@ -22,7 +22,7 @@ #include <thrift/concurrency/Thread.h> -#include <boost/shared_ptr.hpp> +#include <thrift/stdcxx.h> namespace apache { namespace thrift { @@ -38,9 +38,8 @@ class BoostThreadFactory : public ThreadFactory { public: /** * Boost thread factory. All threads created by a factory are reference-counted - * via boost::shared_ptr and boost::weak_ptr. The factory guarantees that threads and - * the Runnable tasks they host will be properly cleaned up once the last strong reference - * to both is given up. + * via stdcxx::shared_ptr. The factory guarantees that threads and the Runnable tasks they + * host will be properly cleaned up once the last strong reference to both is given up. * * Threads are created with the specified boost policy, priority, stack-size. A detachable thread * is not joinable. @@ -51,7 +50,7 @@ public: BoostThreadFactory(bool detached = true); // From ThreadFactory; - boost::shared_ptr<Thread> newThread(boost::shared_ptr<Runnable> runnable) const; + stdcxx::shared_ptr<Thread> newThread(stdcxx::shared_ptr<Runnable> runnable) const; // From ThreadFactory; Thread::id_t getCurrentThreadId() const; http://git-wip-us.apache.org/repos/asf/thrift/blob/82ae9575/lib/cpp/src/thrift/concurrency/FunctionRunner.h ---------------------------------------------------------------------- diff --git a/lib/cpp/src/thrift/concurrency/FunctionRunner.h b/lib/cpp/src/thrift/concurrency/FunctionRunner.h index 9c085c0..eabf019 100644 --- a/lib/cpp/src/thrift/concurrency/FunctionRunner.h +++ b/lib/cpp/src/thrift/concurrency/FunctionRunner.h @@ -20,8 +20,8 @@ #ifndef _THRIFT_CONCURRENCY_FUNCTION_RUNNER_H #define _THRIFT_CONCURRENCY_FUNCTION_RUNNER_H 1 -#include <thrift/cxxfunctional.h> #include <thrift/concurrency/Thread.h> +#include <thrift/stdcxx.h> namespace apache { namespace thrift { @@ -53,20 +53,20 @@ public: // This is the type of callback 'pthread_create()' expects. typedef void* (*PthreadFuncPtr)(void* arg); // This a fully-generic void(void) callback for custom bindings. - typedef apache::thrift::stdcxx::function<void()> VoidFunc; + typedef stdcxx::function<void()> VoidFunc; - typedef apache::thrift::stdcxx::function<bool()> BoolFunc; + typedef stdcxx::function<bool()> BoolFunc; /** * Syntactic sugar to make it easier to create new FunctionRunner * objects wrapped in shared_ptr. */ - static boost::shared_ptr<FunctionRunner> create(const VoidFunc& cob) { - return boost::shared_ptr<FunctionRunner>(new FunctionRunner(cob)); + static stdcxx::shared_ptr<FunctionRunner> create(const VoidFunc& cob) { + return stdcxx::shared_ptr<FunctionRunner>(new FunctionRunner(cob)); } - static boost::shared_ptr<FunctionRunner> create(PthreadFuncPtr func, void* arg) { - return boost::shared_ptr<FunctionRunner>(new FunctionRunner(func, arg)); + static stdcxx::shared_ptr<FunctionRunner> create(PthreadFuncPtr func, void* arg) { + return stdcxx::shared_ptr<FunctionRunner>(new FunctionRunner(func, arg)); } private: @@ -81,7 +81,7 @@ public: * execute the given callback. Note that the 'void*' return value is ignored. */ FunctionRunner(PthreadFuncPtr func, void* arg) - : func_(apache::thrift::stdcxx::bind(pthread_func_wrapper, func, arg)), intervalMs_(-1) {} + : func_(stdcxx::bind(pthread_func_wrapper, func, arg)), intervalMs_(-1) {} /** * Given a generic callback, this FunctionRunner will execute it. http://git-wip-us.apache.org/repos/asf/thrift/blob/82ae9575/lib/cpp/src/thrift/concurrency/Monitor.cpp ---------------------------------------------------------------------- diff --git a/lib/cpp/src/thrift/concurrency/Monitor.cpp b/lib/cpp/src/thrift/concurrency/Monitor.cpp index 5969e4a..af4fcd0 100644 --- a/lib/cpp/src/thrift/concurrency/Monitor.cpp +++ b/lib/cpp/src/thrift/concurrency/Monitor.cpp @@ -23,8 +23,7 @@ #include <thrift/concurrency/Exception.h> #include <thrift/concurrency/Util.h> #include <thrift/transport/PlatformSocket.h> - -#include <boost/scoped_ptr.hpp> +#include <thrift/stdcxx.h> #include <assert.h> @@ -34,9 +33,11 @@ namespace apache { namespace thrift { -namespace concurrency { -using boost::scoped_ptr; +using stdcxx::scoped_ptr; +using stdcxx::shared_ptr; + +namespace concurrency { /** * Monitor implementation using the POSIX pthread library http://git-wip-us.apache.org/repos/asf/thrift/blob/82ae9575/lib/cpp/src/thrift/concurrency/Mutex.cpp ---------------------------------------------------------------------- diff --git a/lib/cpp/src/thrift/concurrency/Mutex.cpp b/lib/cpp/src/thrift/concurrency/Mutex.cpp index bcab05e..a526461 100644 --- a/lib/cpp/src/thrift/concurrency/Mutex.cpp +++ b/lib/cpp/src/thrift/concurrency/Mutex.cpp @@ -34,8 +34,6 @@ #include <string.h> #include <boost/format.hpp> -#include <boost/shared_ptr.hpp> -using boost::shared_ptr; namespace apache { namespace thrift { http://git-wip-us.apache.org/repos/asf/thrift/blob/82ae9575/lib/cpp/src/thrift/concurrency/Mutex.h ---------------------------------------------------------------------- diff --git a/lib/cpp/src/thrift/concurrency/Mutex.h b/lib/cpp/src/thrift/concurrency/Mutex.h index e1e395e..09b938e 100644 --- a/lib/cpp/src/thrift/concurrency/Mutex.h +++ b/lib/cpp/src/thrift/concurrency/Mutex.h @@ -20,7 +20,7 @@ #ifndef _THRIFT_CONCURRENCY_MUTEX_H_ #define _THRIFT_CONCURRENCY_MUTEX_H_ 1 -#include <boost/shared_ptr.hpp> +#include <thrift/stdcxx.h> #include <boost/noncopyable.hpp> #include <stdint.h> @@ -86,7 +86,7 @@ public: private: class impl; - boost::shared_ptr<impl> impl_; + stdcxx::shared_ptr<impl> impl_; }; class ReadWriteMutex { @@ -107,7 +107,7 @@ public: private: class impl; - boost::shared_ptr<impl> impl_; + stdcxx::shared_ptr<impl> impl_; }; /**