diff options
author | James E. King, III <jim.king@simplivity.com> | 2017-08-05 12:23:54 -0400 |
---|---|---|
committer | James E. King, III <jking@apache.org> | 2017-08-10 13:27:21 -0400 |
commit | 82ae9575cdc112088771fc7b876f75e1e4d85ebb (patch) | |
tree | d8e6827311ee6e69c560604fe660788b7dfd4908 | |
parent | 0a8c34ceedf0f9272fb6d3519596ddf90cffcac2 (diff) | |
download | thrift-82ae9575cdc112088771fc7b876f75e1e4d85ebb.tar.gz |
THRIFT-2221: detect C++11 and use std namespace for memory operations (smart_ptr)
Client: C++
This closes #1328
153 files changed, 1762 insertions, 1672 deletions
diff --git a/appveyor.yml b/appveyor.yml index 42c291124..fc09f87f9 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 diff --git a/build/appveyor/MSVC-appveyor-build.bat b/build/appveyor/MSVC-appveyor-build.bat index 054a8b414..a4b92a29c 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%" ^ diff --git a/build/cmake/DefineCMakeDefaults.cmake b/build/cmake/DefineCMakeDefaults.cmake index 365c0a434..28999379f 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() diff --git a/build/cmake/DefineOptions.cmake b/build/cmake/DefineOptions.cmake index 63981e94d..f1ea7bbc3 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}") diff --git a/build/cmake/DefinePlatformSpecifc.cmake b/build/cmake/DefinePlatformSpecifc.cmake index d5d27e2d0..f4434891c 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() diff --git a/build/cmake/NewPlatformDebug.cmake b/build/cmake/NewPlatformDebug.cmake index 76cac15c2..aa4d30230 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") diff --git a/compiler/cpp/src/thrift/generate/t_cpp_generator.cc b/compiler/cpp/src/thrift/generate/t_cpp_generator.cc index 0518ec80c..9413b86bb 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"; diff --git a/compiler/cpp/src/thrift/plugin/plugin.cc b/compiler/cpp/src/thrift/plugin/plugin.cc index 1d45d89c7..0bac1352b 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 { diff --git a/compiler/cpp/src/thrift/plugin/plugin_output.cc b/compiler/cpp/src/thrift/plugin/plugin_output.cc index 168a4a660..75725a1c0 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; diff --git a/lib/c_glib/test/testthrifttestclient.cpp b/lib/c_glib/test/testthrifttestclient.cpp index 7681cf52a..5b06883eb 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); diff --git a/lib/cpp/Makefile.am b/lib/cpp/Makefile.am index 64cf98e91..77d4d6c98 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 diff --git a/lib/cpp/README.md b/lib/cpp/README.md index a7f7e792c..e744a6a46 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) diff --git a/lib/cpp/src/thrift/TDispatchProcessor.h b/lib/cpp/src/thrift/TDispatchProcessor.h index fd1dce7af..dadc87b5c 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; diff --git a/lib/cpp/src/thrift/TProcessor.h b/lib/cpp/src/thrift/TProcessor.h index 4a0604eac..27294d3ec 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 diff --git a/lib/cpp/src/thrift/async/TAsyncBufferProcessor.h b/lib/cpp/src/thrift/async/TAsyncBufferProcessor.h index 3c957a622..0d56c78d0 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() {} }; } diff --git a/lib/cpp/src/thrift/async/TAsyncChannel.cpp b/lib/cpp/src/thrift/async/TAsyncChannel.cpp index 4716af2ea..c87659fca 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 { diff --git a/lib/cpp/src/thrift/async/TAsyncChannel.h b/lib/cpp/src/thrift/async/TAsyncChannel.h index eb3ce2a68..f8d2b036a 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 { diff --git a/lib/cpp/src/thrift/async/TAsyncDispatchProcessor.h b/lib/cpp/src/thrift/async/TAsyncDispatchProcessor.h index e79c57dfb..a1450f015 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(); diff --git a/lib/cpp/src/thrift/async/TAsyncProcessor.h b/lib/cpp/src/thrift/async/TAsyncProcessor.h index 01a34c4f4..afc4ffaa4 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; } } diff --git a/lib/cpp/src/thrift/async/TAsyncProtocolProcessor.cpp b/lib/cpp/src/thrift/async/TAsyncProtocolProcessor.cpp index 5a4f3477e..b9ffb0448 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. diff --git a/lib/cpp/src/thrift/async/TAsyncProtocolProcessor.h b/lib/cpp/src/thrift/async/TAsyncProtocolProcessor.h index 3f2b39446..ce3883c2f 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_; }; } } diff --git a/lib/cpp/src/thrift/async/TConcurrentClientSyncInfo.h b/lib/cpp/src/thrift/async/TConcurrentClientSyncInfo.h index 7afcbc2da..9ec77b962 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: diff --git a/lib/cpp/src/thrift/async/TEvhttpClientChannel.h b/lib/cpp/src/thrift/async/TEvhttpClientChannel.h index 72eb32dd1..977495276 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; diff --git a/lib/cpp/src/thrift/async/TEvhttpServer.cpp b/lib/cpp/src/thrift/async/TEvhttpServer.cpp index 4fa41f8f0..d87e507d8 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"; diff --git a/lib/cpp/src/thrift/async/TEvhttpServer.h b/lib/cpp/src/thrift/async/TEvhttpServer.h index 89bf337b0..afc679ccf 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_; }; diff --git a/lib/cpp/src/thrift/concurrency/BoostMonitor.cpp b/lib/cpp/src/thrift/concurrency/BoostMonitor.cpp index 6c24d8249..ebfa0b9dd 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_; }; diff --git a/lib/cpp/src/thrift/concurrency/BoostThreadFactory.cpp b/lib/cpp/src/thrift/concurrency/BoostThreadFactory.cpp index 8afabf9ec..3661275e8 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(); diff --git a/lib/cpp/src/thrift/concurrency/BoostThreadFactory.h b/lib/cpp/src/thrift/concurrency/BoostThreadFactory.h index 7973245a0..4c7a45abb 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; diff --git a/lib/cpp/src/thrift/concurrency/FunctionRunner.h b/lib/cpp/src/thrift/concurrency/FunctionRunner.h index 9c085c03f..eabf019b7 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. diff --git a/lib/cpp/src/thrift/concurrency/Monitor.cpp b/lib/cpp/src/thrift/concurrency/Monitor.cpp index 5969e4a45..af4fcd09c 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 diff --git a/lib/cpp/src/thrift/concurrency/Mutex.cpp b/lib/cpp/src/thrift/concurrency/Mutex.cpp index bcab05ec3..a5264617d 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 { diff --git a/lib/cpp/src/thrift/concurrency/Mutex.h b/lib/cpp/src/thrift/concurrency/Mutex.h index e1e395edd..09b938e5b 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_; }; /** diff --git a/lib/cpp/src/thrift/concurrency/PosixThreadFactory.cpp b/lib/cpp/src/thrift/concurrency/PosixThreadFactory.cpp index 6a0b47cb4..6bf043bce 100644 --- a/lib/cpp/src/thrift/concurrency/PosixThreadFactory.cpp +++ b/lib/cpp/src/thrift/concurrency/PosixThreadFactory.cpp @@ -31,15 +31,12 @@ #include <iostream> -#include <boost/weak_ptr.hpp> +#include <thrift/stdcxx.h> namespace apache { namespace thrift { namespace concurrency { -using boost::shared_ptr; -using boost::weak_ptr; - /** * The POSIX thread class. * @@ -59,7 +56,7 @@ private: int policy_; int priority_; int stackSize_; - weak_ptr<PthreadThread> self_; + stdcxx::weak_ptr<PthreadThread> self_; bool detached_; public: @@ -67,7 +64,7 @@ public: int priority, int stackSize, bool detached, - shared_ptr<Runnable> runnable) + stdcxx::shared_ptr<Runnable> runnable) : #ifndef _WIN32 @@ -139,7 +136,7 @@ public: } // Create reference - shared_ptr<PthreadThread>* selfRef = new shared_ptr<PthreadThread>(); + stdcxx::shared_ptr<PthreadThread>* selfRef = new stdcxx::shared_ptr<PthreadThread>(); *selfRef = self_.lock(); state_ = starting; @@ -178,19 +175,19 @@ public: #endif // _WIN32 } - shared_ptr<Runnable> runnable() const { return Thread::runnable(); } + stdcxx::shared_ptr<Runnable> runnable() const { return Thread::runnable(); } - void runnable(shared_ptr<Runnable> value) { Thread::runnable(value); } + void runnable(stdcxx::shared_ptr<Runnable> value) { Thread::runnable(value); } - void weakRef(shared_ptr<PthreadThread> self) { + void weakRef(stdcxx::shared_ptr<PthreadThread> self) { assert(self.get() == this); - self_ = weak_ptr<PthreadThread>(self); + self_ = stdcxx::weak_ptr<PthreadThread>(self); } }; void* PthreadThread::threadMain(void* arg) { - shared_ptr<PthreadThread> thread = *(shared_ptr<PthreadThread>*)arg; - delete reinterpret_cast<shared_ptr<PthreadThread>*>(arg); + stdcxx::shared_ptr<PthreadThread> thread = *(stdcxx::shared_ptr<PthreadThread>*)arg; + delete reinterpret_cast<stdcxx::shared_ptr<PthreadThread>*>(arg); if (thread == NULL) { return (void*)0; @@ -276,9 +273,9 @@ PosixThreadFactory::PosixThreadFactory(bool detached) stackSize_(1) { } -shared_ptr<Thread> PosixThreadFactory::newThread(shared_ptr<Runnable> runnable) const { - shared_ptr<PthreadThread> result - = shared_ptr<PthreadThread>(new PthreadThread(toPthreadPolicy(policy_), +stdcxx::shared_ptr<Thread> PosixThreadFactory::newThread(stdcxx::shared_ptr<Runnable> runnable) const { + stdcxx::shared_ptr<PthreadThread> result + = stdcxx::shared_ptr<PthreadThread>(new PthreadThread(toPthreadPolicy(policy_), toPthreadPriority(policy_, priority_), stackSize_, isDetached(), diff --git a/lib/cpp/src/thrift/concurrency/PosixThreadFactory.h b/lib/cpp/src/thrift/concurrency/PosixThreadFactory.h index c1bbe5c3b..5e04d01d3 100644 --- a/lib/cpp/src/thrift/concurrency/PosixThreadFactory.h +++ b/lib/cpp/src/thrift/concurrency/PosixThreadFactory.h @@ -22,7 +22,7 @@ #include <thrift/concurrency/Thread.h> -#include <boost/shared_ptr.hpp> +#include <thrift/stdcxx.h> namespace apache { namespace thrift { @@ -63,9 +63,9 @@ public: /** * Posix thread (pthread) 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 policy, priority, stack-size and detachable-mode * detached means the thread is free-running and will release all system resources the @@ -88,7 +88,7 @@ public: PosixThreadFactory(bool detached); // 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; diff --git a/lib/cpp/src/thrift/concurrency/StdThreadFactory.cpp b/lib/cpp/src/thrift/concurrency/StdThreadFactory.cpp index 4fca8da55..4067f2418 100644 --- a/lib/cpp/src/thrift/concurrency/StdThreadFactory.cpp +++ b/lib/cpp/src/thrift/concurrency/StdThreadFactory.cpp @@ -23,11 +23,9 @@ #include <thrift/concurrency/StdThreadFactory.h> #include <thrift/concurrency/Exception.h> +#include <thrift/stdcxx.h> #include <cassert> - -#include <boost/enable_shared_from_this.hpp> -#include <boost/weak_ptr.hpp> #include <thread> namespace apache { @@ -43,11 +41,11 @@ namespace concurrency { * * @version $Id:$ */ -class StdThread : public Thread, public boost::enable_shared_from_this<StdThread> { +class StdThread : public Thread, public stdcxx::enable_shared_from_this<StdThread> { public: enum STATE { uninitialized, starting, started, stopping, stopped }; - static void threadMain(boost::shared_ptr<StdThread> thread); + static void threadMain(stdcxx::shared_ptr<StdThread> thread); private: std::unique_ptr<std::thread> thread_; @@ -55,7 +53,7 @@ private: bool detached_; public: - StdThread(bool detached, boost::shared_ptr<Runnable> runnable) + StdThread(bool detached, stdcxx::shared_ptr<Runnable> runnable) : state_(uninitialized), detached_(detached) { this->Thread::runnable(runnable); } @@ -75,7 +73,7 @@ public: return; } - boost::shared_ptr<StdThread> selfRef = shared_from_this(); + stdcxx::shared_ptr<StdThread> selfRef = shared_from_this(); state_ = starting; thread_ = std::unique_ptr<std::thread>(new std::thread(threadMain, selfRef)); @@ -92,12 +90,12 @@ public: Thread::id_t getId() { return thread_.get() ? thread_->get_id() : std::thread::id(); } - boost::shared_ptr<Runnable> runnable() const { return Thread::runnable(); } + stdcxx::shared_ptr<Runnable> runnable() const { return Thread::runnable(); } - void runnable(boost::shared_ptr<Runnable> value) { Thread::runnable(value); } + void runnable(stdcxx::shared_ptr<Runnable> value) { Thread::runnable(value); } }; -void StdThread::threadMain(boost::shared_ptr<StdThread> thread) { +void StdThread::threadMain(stdcxx::shared_ptr<StdThread> thread) { if (thread == NULL) { return; } @@ -119,8 +117,8 @@ void StdThread::threadMain(boost::shared_ptr<StdThread> thread) { StdThreadFactory::StdThreadFactory(bool detached) : ThreadFactory(detached) { } -boost::shared_ptr<Thread> StdThreadFactory::newThread(boost::shared_ptr<Runnable> runnable) const { - boost::shared_ptr<StdThread> result = boost::shared_ptr<StdThread>(new StdThread(isDetached(), runnable)); +stdcxx::shared_ptr<Thread> StdThreadFactory::newThread(stdcxx::shared_ptr<Runnable> runnable) const { + stdcxx::shared_ptr<StdThread> result = stdcxx::shared_ptr<StdThread>(new StdThread(isDetached(), runnable)); runnable->thread(result); return result; } diff --git a/lib/cpp/src/thrift/concurrency/StdThreadFactory.h b/lib/cpp/src/thrift/concurrency/StdThreadFactory.h index 88f00bea4..8e116b64a 100644 --- a/lib/cpp/src/thrift/concurrency/StdThreadFactory.h +++ b/lib/cpp/src/thrift/concurrency/StdThreadFactory.h @@ -22,7 +22,7 @@ #include <thrift/concurrency/Thread.h> -#include <boost/shared_ptr.hpp> +#include <thrift/stdcxx.h> namespace apache { namespace thrift { @@ -38,8 +38,8 @@ class StdThreadFactory : public ThreadFactory { public: /** * Std 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 + * 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. * * By default threads are not joinable. @@ -48,7 +48,7 @@ public: StdThreadFactory(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; diff --git a/lib/cpp/src/thrift/concurrency/Thread.h b/lib/cpp/src/thrift/concurrency/Thread.h index 2e154899f..788623bda 100644 --- a/lib/cpp/src/thrift/concurrency/Thread.h +++ b/lib/cpp/src/thrift/concurrency/Thread.h @@ -21,8 +21,7 @@ #define _THRIFT_CONCURRENCY_THREAD_H_ 1 #include <stdint.h> -#include <boost/shared_ptr.hpp> -#include <boost/weak_ptr.hpp> +#include <thrift/stdcxx.h> #include <thrift/thrift-config.h> @@ -57,16 +56,16 @@ public: * Gets the thread object that is hosting this runnable object - can return * an empty boost::shared pointer if no references remain on that thread object */ - virtual boost::shared_ptr<Thread> thread() { return thread_.lock(); } + virtual stdcxx::shared_ptr<Thread> thread() { return thread_.lock(); } /** * Sets the thread that is executing this object. This is only meant for * use by concrete implementations of Thread. */ - virtual void thread(boost::shared_ptr<Thread> value) { thread_ = value; } + virtual void thread(stdcxx::shared_ptr<Thread> value) { thread_ = value; } private: - boost::weak_ptr<Thread> thread_; + stdcxx::weak_ptr<Thread> thread_; }; /** @@ -122,13 +121,13 @@ public: /** * Gets the runnable object this thread is hosting */ - virtual boost::shared_ptr<Runnable> runnable() const { return _runnable; } + virtual stdcxx::shared_ptr<Runnable> runnable() const { return _runnable; } protected: - virtual void runnable(boost::shared_ptr<Runnable> value) { _runnable = value; } + virtual void runnable(stdcxx::shared_ptr<Runnable> value) { _runnable = value; } private: - boost::shared_ptr<Runnable> _runnable; + stdcxx::shared_ptr<Runnable> _runnable; }; /** @@ -155,7 +154,7 @@ public: /** * Create a new thread. */ - virtual boost::shared_ptr<Thread> newThread(boost::shared_ptr<Runnable> runnable) const = 0; + virtual stdcxx::shared_ptr<Thread> newThread(stdcxx::shared_ptr<Runnable> runnable) const = 0; /** * Gets the current thread id or unknown_thread_id if the current thread is not a thrift thread diff --git a/lib/cpp/src/thrift/concurrency/ThreadManager.cpp b/lib/cpp/src/thrift/concurrency/ThreadManager.cpp index 88cd59a24..2e27b7f42 100644 --- a/lib/cpp/src/thrift/concurrency/ThreadManager.cpp +++ b/lib/cpp/src/thrift/concurrency/ThreadManager.cpp @@ -24,7 +24,7 @@ #include <thrift/concurrency/Monitor.h> #include <thrift/concurrency/Util.h> -#include <boost/shared_ptr.hpp> +#include <thrift/stdcxx.h> #include <stdexcept> #include <deque> @@ -34,8 +34,8 @@ namespace apache { namespace thrift { namespace concurrency { -using boost::shared_ptr; -using boost::dynamic_pointer_cast; +using stdcxx::shared_ptr; +using stdcxx::dynamic_pointer_cast; /** * ThreadManager class @@ -504,7 +504,7 @@ void ThreadManager::Impl::remove(shared_ptr<Runnable> task) { } } -boost::shared_ptr<Runnable> ThreadManager::Impl::removeNextPending() { +stdcxx::shared_ptr<Runnable> ThreadManager::Impl::removeNextPending() { Guard g(mutex_); if (state_ != ThreadManager::STARTED) { throw IllegalStateException( @@ -513,7 +513,7 @@ boost::shared_ptr<Runnable> ThreadManager::Impl::removeNextPending() { } if (tasks_.empty()) { - return boost::shared_ptr<Runnable>(); + return stdcxx::shared_ptr<Runnable>(); } shared_ptr<ThreadManager::Task> task = tasks_.front(); diff --git a/lib/cpp/src/thrift/concurrency/ThreadManager.h b/lib/cpp/src/thrift/concurrency/ThreadManager.h index d8bf71b8d..b3b75421d 100644 --- a/lib/cpp/src/thrift/concurrency/ThreadManager.h +++ b/lib/cpp/src/thrift/concurrency/ThreadManager.h @@ -20,10 +20,9 @@ #ifndef _THRIFT_CONCURRENCY_THREADMANAGER_H_ #define _THRIFT_CONCURRENCY_THREADMANAGER_H_ 1 -#include <boost/shared_ptr.hpp> -#include <thrift/cxxfunctional.h> #include <sys/types.h> #include <thrift/concurrency/Thread.h> +#include <thrift/stdcxx.h> namespace apache { namespace thrift { @@ -59,7 +58,7 @@ protected: ThreadManager() {} public: - typedef apache::thrift::stdcxx::function<void(boost::shared_ptr<Runnable>)> ExpireCallback; + typedef apache::thrift::stdcxx::function<void(stdcxx::shared_ptr<Runnable>)> ExpireCallback; virtual ~ThreadManager() {} @@ -88,14 +87,14 @@ public: /** * \returns the current thread factory */ - virtual boost::shared_ptr<ThreadFactory> threadFactory() const = 0; + virtual stdcxx::shared_ptr<ThreadFactory> threadFactory() const = 0; /** * Set the thread factory. * \throws InvalidArgumentException if the new thread factory has a different * detached disposition than the one replacing it */ - virtual void threadFactory(boost::shared_ptr<ThreadFactory> value) = 0; + virtual void threadFactory(stdcxx::shared_ptr<ThreadFactory> value) = 0; /** * Adds worker thread(s). @@ -162,21 +161,21 @@ public: * * @throws TooManyPendingTasksException Pending task count exceeds max pending task count */ - virtual void add(boost::shared_ptr<Runnable> task, + virtual void add(stdcxx::shared_ptr<Runnable> task, int64_t timeout = 0LL, int64_t expiration = 0LL) = 0; /** * Removes a pending task */ - virtual void remove(boost::shared_ptr<Runnable> task) = 0; + virtual void remove(stdcxx::shared_ptr<Runnable> task) = 0; /** * Remove the next pending task which would be run. * * @return the task removed. */ - virtual boost::shared_ptr<Runnable> removeNextPending() = 0; + virtual stdcxx::shared_ptr<Runnable> removeNextPending() = 0; /** * Remove tasks from front of task queue that have expired. @@ -191,14 +190,14 @@ public: */ virtual void setExpireCallback(ExpireCallback expireCallback) = 0; - static boost::shared_ptr<ThreadManager> newThreadManager(); + static stdcxx::shared_ptr<ThreadManager> newThreadManager(); /** * Creates a simple thread manager the uses count number of worker threads and has * a pendingTaskCountMax maximum pending tasks. The default, 0, specified no limit * on pending tasks */ - static boost::shared_ptr<ThreadManager> newSimpleThreadManager(size_t count = 4, + static stdcxx::shared_ptr<ThreadManager> newSimpleThreadManager(size_t count = 4, size_t pendingTaskCountMax = 0); class Task; diff --git a/lib/cpp/src/thrift/concurrency/TimerManager.cpp b/lib/cpp/src/thrift/concurrency/TimerManager.cpp index f95fcda4d..b03ff42af 100644 --- a/lib/cpp/src/thrift/concurrency/TimerManager.cpp +++ b/lib/cpp/src/thrift/concurrency/TimerManager.cpp @@ -29,7 +29,7 @@ namespace apache { namespace thrift { namespace concurrency { -using boost::shared_ptr; +using stdcxx::shared_ptr; /** * TimerManager class diff --git a/lib/cpp/src/thrift/concurrency/TimerManager.h b/lib/cpp/src/thrift/concurrency/TimerManager.h index 39468273e..f6643483d 100644 --- a/lib/cpp/src/thrift/concurrency/TimerManager.h +++ b/lib/cpp/src/thrift/concurrency/TimerManager.h @@ -24,7 +24,7 @@ #include <thrift/concurrency/Monitor.h> #include <thrift/concurrency/Thread.h> -#include <boost/shared_ptr.hpp> +#include <thrift/stdcxx.h> #include <map> #include <time.h> @@ -46,9 +46,9 @@ public: virtual ~TimerManager(); - virtual boost::shared_ptr<const ThreadFactory> threadFactory() const; + virtual stdcxx::shared_ptr<const ThreadFactory> threadFactory() const; - virtual void threadFactory(boost::shared_ptr<const ThreadFactory> value); + virtual void threadFactory(stdcxx::shared_ptr<const ThreadFactory> value); /** * Starts the timer manager service @@ -70,7 +70,7 @@ public: * @param task The task to execute * @param timeout Time in milliseconds to delay before executing task */ - virtual void add(boost::shared_ptr<Runnable> task, int64_t timeout); + virtual void add(stdcxx::shared_ptr<Runnable> task, int64_t timeout); /** * Adds a task to be executed at some time in the future by a worker thread. @@ -78,7 +78,7 @@ public: * @param task The task to execute * @param timeout Absolute time in the future to execute task. */ - virtual void add(boost::shared_ptr<Runnable> task, const struct THRIFT_TIMESPEC& timeout); + virtual void add(stdcxx::shared_ptr<Runnable> task, const struct THRIFT_TIMESPEC& timeout); /** * Adds a task to be executed at some time in the future by a worker thread. @@ -86,7 +86,7 @@ public: * @param task The task to execute * @param timeout Absolute time in the future to execute task. */ - virtual void add(boost::shared_ptr<Runnable> task, const struct timeval& timeout); + virtual void add(stdcxx::shared_ptr<Runnable> task, const struct timeval& timeout); /** * Removes a pending task @@ -98,25 +98,25 @@ public: * @throws UncancellableTaskException Specified task is already being * executed or has completed execution. */ - virtual void remove(boost::shared_ptr<Runnable> task); + virtual void remove(stdcxx::shared_ptr<Runnable> task); enum STATE { UNINITIALIZED, STARTING, STARTED, STOPPING, STOPPED }; virtual STATE state() const; private: - boost::shared_ptr<const ThreadFactory> threadFactory_; + stdcxx::shared_ptr<const ThreadFactory> threadFactory_; class Task; friend class Task; - std::multimap<int64_t, boost::shared_ptr<Task> > taskMap_; + std::multimap<int64_t, stdcxx::shared_ptr<Task> > taskMap_; size_t taskCount_; Monitor monitor_; STATE state_; class Dispatcher; friend class Dispatcher; - boost::shared_ptr<Dispatcher> dispatcher_; - boost::shared_ptr<Thread> dispatcherThread_; - typedef std::multimap<int64_t, boost::shared_ptr<TimerManager::Task> >::iterator task_iterator; + stdcxx::shared_ptr<Dispatcher> dispatcher_; + stdcxx::shared_ptr<Thread> dispatcherThread_; + typedef std::multimap<int64_t, stdcxx::shared_ptr<TimerManager::Task> >::iterator task_iterator; typedef std::pair<task_iterator, task_iterator> task_range; }; } diff --git a/lib/cpp/src/thrift/cxxfunctional.h b/lib/cpp/src/thrift/cxxfunctional.h deleted file mode 100644 index 32933a439..000000000 --- a/lib/cpp/src/thrift/cxxfunctional.h +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#ifndef _THRIFT_CXXFUNCTIONAL_H_ -#define _THRIFT_CXXFUNCTIONAL_H_ 1 - -// clang-format off - -/** - * Loads <functional> from the 'right' location, depending - * on compiler and whether or not it's using C++03 with TR1 - * or C++11. - */ - -/* - * MSVC 10 and 11 have the <functional> stuff at <functional>. - * In MSVC 10 all of the implementations live in std::tr1. - * In MSVC 11 all of the implementations live in std, with aliases - * in std::tr1 to point to the ones in std. - */ -#if defined(_WIN32) && !defined(__MINGW32__) - #define _THRIFT_USING_MICROSOFT_STDLIB 1 -#endif - -#ifdef __clang__ - /* Clang has two options, depending on standard library: - * - no -stdlib or -stdlib=libstdc++ set; uses GNU libstdc++. - * <tr1/functional> - * - -stdlib=libc++; uses LLVM libc++. - * <functional>, no 'std::tr1'. - * - * The compiler itself doesn't define anything differently - * depending on the value of -stdlib, but the library headers - * will set different preprocessor options. In order to check, - * though, we have to pull in some library header. - */ - #include <utility> - - /* With LLVM libc++, utility pulls in __config, which sets - _LIBCPP_VERSION. */ - #if defined(_LIBCPP_VERSION) - #define _THRIFT_USING_CLANG_LIBCXX 1 - - /* With GNU libstdc++, utility pulls in bits/c++config.h, - which sets __GLIBCXX__. */ - #elif defined(__GLIBCXX__) - #define _THRIFT_USING_GNU_LIBSTDCXX 1 - - /* No idea. */ - #else - #error Unable to detect which C++ standard library is in use. - #endif -#elif __GNUC__ - #define _THRIFT_USING_GNU_LIBSTDCXX 1 -#endif - -#if _THRIFT_USING_MICROSOFT_STDLIB - #include <functional> - - namespace apache { namespace thrift { namespace stdcxx { - using ::std::tr1::function; - using ::std::tr1::bind; - - namespace placeholders { - using ::std::tr1::placeholders::_1; - using ::std::tr1::placeholders::_2; - using ::std::tr1::placeholders::_3; - using ::std::tr1::placeholders::_4; - using ::std::tr1::placeholders::_5; - using ::std::tr1::placeholders::_6; - } // apache::thrift::stdcxx::placeholders - }}} // apache::thrift::stdcxx - -#elif _THRIFT_USING_CLANG_LIBCXX - #include <functional> - - namespace apache { namespace thrift { namespace stdcxx { - using ::std::function; - using ::std::bind; - - namespace placeholders { - using ::std::placeholders::_1; - using ::std::placeholders::_2; - using ::std::placeholders::_3; - using ::std::placeholders::_4; - using ::std::placeholders::_5; - using ::std::placeholders::_6; - } // apache::thrift::stdcxx::placeholders - }}} // apache::thrift::stdcxx - -#elif _THRIFT_USING_GNU_LIBSTDCXX - #ifdef USE_BOOST_THREAD - #include <boost/tr1/functional.hpp> - #else - #include <tr1/functional> - #endif - - namespace apache { namespace thrift { namespace stdcxx { - using ::std::tr1::function; - using ::std::tr1::bind; - - namespace placeholders { - using ::std::tr1::placeholders::_1; - using ::std::tr1::placeholders::_2; - using ::std::tr1::placeholders::_3; - using ::std::tr1::placeholders::_4; - using ::std::tr1::placeholders::_5; - using ::std::tr1::placeholders::_6; - } // apache::thrift::stdcxx::placeholders - }}} // apache::thrift::stdcxx -#endif - - // Alias for thrift c++ compatibility namespace - namespace tcxx = apache::thrift::stdcxx; - -#endif // #ifndef _THRIFT_CXXFUNCTIONAL_H_ diff --git a/lib/cpp/src/thrift/processor/PeekProcessor.cpp b/lib/cpp/src/thrift/processor/PeekProcessor.cpp index 8c9a463b3..fa11a721c 100644 --- a/lib/cpp/src/thrift/processor/PeekProcessor.cpp +++ b/lib/cpp/src/thrift/processor/PeekProcessor.cpp @@ -34,26 +34,26 @@ PeekProcessor::PeekProcessor() { PeekProcessor::~PeekProcessor() { } -void PeekProcessor::initialize(boost::shared_ptr<TProcessor> actualProcessor, - boost::shared_ptr<TProtocolFactory> protocolFactory, - boost::shared_ptr<TPipedTransportFactory> transportFactory) { +void PeekProcessor::initialize(stdcxx::shared_ptr<TProcessor> actualProcessor, + stdcxx::shared_ptr<TProtocolFactory> protocolFactory, + stdcxx::shared_ptr<TPipedTransportFactory> transportFactory) { actualProcessor_ = actualProcessor; pipedProtocol_ = protocolFactory->getProtocol(targetTransport_); transportFactory_ = transportFactory; transportFactory_->initializeTargetTransport(targetTransport_); } -boost::shared_ptr<TTransport> PeekProcessor::getPipedTransport(boost::shared_ptr<TTransport> in) { +stdcxx::shared_ptr<TTransport> PeekProcessor::getPipedTransport(stdcxx::shared_ptr<TTransport> in) { return transportFactory_->getTransport(in); } -void PeekProcessor::setTargetTransport(boost::shared_ptr<TTransport> targetTransport) { +void PeekProcessor::setTargetTransport(stdcxx::shared_ptr<TTransport> targetTransport) { targetTransport_ = targetTransport; - if (boost::dynamic_pointer_cast<TMemoryBuffer>(targetTransport_)) { - memoryBuffer_ = boost::dynamic_pointer_cast<TMemoryBuffer>(targetTransport); - } else if (boost::dynamic_pointer_cast<TPipedTransport>(targetTransport_)) { - memoryBuffer_ = boost::dynamic_pointer_cast<TMemoryBuffer>( - boost::dynamic_pointer_cast<TPipedTransport>(targetTransport_)->getTargetTransport()); + if (stdcxx::dynamic_pointer_cast<TMemoryBuffer>(targetTransport_)) { + memoryBuffer_ = stdcxx::dynamic_pointer_cast<TMemoryBuffer>(targetTransport); + } else if (stdcxx::dynamic_pointer_cast<TPipedTransport>(targetTransport_)) { + memoryBuffer_ = stdcxx::dynamic_pointer_cast<TMemoryBuffer>( + stdcxx::dynamic_pointer_cast<TPipedTransport>(targetTransport_)->getTargetTransport()); } if (!memoryBuffer_) { @@ -62,8 +62,8 @@ void PeekProcessor::setTargetTransport(boost::shared_ptr<TTransport> targetTrans } } -bool PeekProcessor::process(boost::shared_ptr<TProtocol> in, - boost::shared_ptr<TProtocol> out, +bool PeekProcessor::process(stdcxx::shared_ptr<TProtocol> in, + stdcxx::shared_ptr<TProtocol> out, void* connectionContext) { std::string fname; @@ -120,7 +120,7 @@ void PeekProcessor::peekBuffer(uint8_t* buffer, uint32_t size) { (void)size; } -void PeekProcessor::peek(boost::shared_ptr<TProtocol> in, TType ftype, int16_t fid) { +void PeekProcessor::peek(stdcxx::shared_ptr<TProtocol> in, TType ftype, int16_t fid) { (void)fid; in->skip(ftype); } diff --git a/lib/cpp/src/thrift/processor/PeekProcessor.h b/lib/cpp/src/thrift/processor/PeekProcessor.h index 21c599948..f5c10da68 100644 --- a/lib/cpp/src/thrift/processor/PeekProcessor.h +++ b/lib/cpp/src/thrift/processor/PeekProcessor.h @@ -25,7 +25,7 @@ #include <thrift/transport/TTransport.h> #include <thrift/transport/TTransportUtils.h> #include <thrift/transport/TBufferTransports.h> -#include <boost/shared_ptr.hpp> +#include <thrift/stdcxx.h> namespace apache { namespace thrift { @@ -47,34 +47,34 @@ public: // transportFactory - this TPipedTransportFactory is used to wrap the source transport // via a call to getPipedTransport void initialize( - boost::shared_ptr<apache::thrift::TProcessor> actualProcessor, - boost::shared_ptr<apache::thrift::protocol::TProtocolFactory> protocolFactory, - boost::shared_ptr<apache::thrift::transport::TPipedTransportFactory> transportFactory); + stdcxx::shared_ptr<apache::thrift::TProcessor> actualProcessor, + stdcxx::shared_ptr<apache::thrift::protocol::TProtocolFactory> protocolFactory, + stdcxx::shared_ptr<apache::thrift::transport::TPipedTransportFactory> transportFactory); - boost::shared_ptr<apache::thrift::transport::TTransport> getPipedTransport( - boost::shared_ptr<apache::thrift::transport::TTransport> in); + stdcxx::shared_ptr<apache::thrift::transport::TTransport> getPipedTransport( + stdcxx::shared_ptr<apache::thrift::transport::TTransport> in); - void setTargetTransport(boost::shared_ptr<apache::thrift::transport::TTransport> targetTransport); + void setTargetTransport(stdcxx::shared_ptr<apache::thrift::transport::TTransport> targetTransport); - virtual bool process(boost::shared_ptr<apache::thrift::protocol::TProtocol> in, - boost::shared_ptr<apache::thrift::protocol::TProtocol> out, + virtual bool process(stdcxx::shared_ptr<apache::thrift::protocol::TProtocol> in, + stdcxx::shared_ptr<apache::thrift::protocol::TProtocol> out, void* connectionContext); // The following three functions can be overloaded by child classes to // achieve desired peeking behavior virtual void peekName(const std::string& fname); virtual void peekBuffer(uint8_t* buffer, uint32_t size); - virtual void peek(boost::shared_ptr<apache::thrift::protocol::TProtocol> in, + virtual void peek(stdcxx::shared_ptr<apache::thrift::protocol::TProtocol> in, apache::thrift::protocol::TType ftype, int16_t fid); virtual void peekEnd(); private: - boost::shared_ptr<apache::thrift::TProcessor> actualProcessor_; - boost::shared_ptr<apache::thrift::protocol::TProtocol> pipedProtocol_; - boost::shared_ptr<apache::thrift::transport::TPipedTransportFactory> transportFactory_; - boost::shared_ptr<apache::thrift::transport::TMemoryBuffer> memoryBuffer_; - boost::shared_ptr<apache::thrift::transport::TTransport> targetTransport_; + stdcxx::shared_ptr<apache::thrift::TProcessor> actualProcessor_; + stdcxx::shared_ptr<apache::thrift::protocol::TProtocol> pipedProtocol_; + stdcxx::shared_ptr<apache::thrift::transport::TPipedTransportFactory> transportFactory_; + stdcxx::shared_ptr<apache::thrift::transport::TMemoryBuffer> memoryBuffer_; + stdcxx::shared_ptr<apache::thrift::transport::TTransport> targetTransport_; }; } } diff --git a/lib/cpp/src/thrift/processor/StatsProcessor.h b/lib/cpp/src/thrift/processor/StatsProcessor.h index e8ca067e9..8f6725f00 100644 --- a/lib/cpp/src/thrift/processor/StatsProcessor.h +++ b/lib/cpp/src/thrift/processor/StatsProcessor.h @@ -20,7 +20,7 @@ #ifndef STATSPROCESSOR_H #define STATSPROCESSOR_H -#include <boost/shared_ptr.hpp> +#include <thrift/stdcxx.h> #include <thrift/transport/TTransport.h> #include <thrift/protocol/TProtocol.h> #include <TProcessor.h> @@ -38,8 +38,8 @@ public: StatsProcessor(bool print, bool frequency) : print_(print), frequency_(frequency) {} virtual ~StatsProcessor(){}; - virtual bool process(boost::shared_ptr<apache::thrift::protocol::TProtocol> piprot, - boost::shared_ptr<apache::thrift::protocol::TProtocol> poprot, + virtual bool process(stdcxx::shared_ptr<apache::thrift::protocol::TProtocol> piprot, + stdcxx::shared_ptr<apache::thrift::protocol::TProtocol> poprot, void* serverContext) { piprot_ = piprot; @@ -229,7 +229,7 @@ protected: } } - boost::shared_ptr<apache::thrift::protocol::TProtocol> piprot_; + stdcxx::shared_ptr<apache::thrift::protocol::TProtocol> piprot_; std::map<std::string, int64_t> frequency_map_; bool print_; diff --git a/lib/cpp/src/thrift/processor/TMultiplexedProcessor.h b/lib/cpp/src/thrift/processor/TMultiplexedProcessor.h index 0ef72616f..13b09bbe9 100644 --- a/lib/cpp/src/thrift/processor/TMultiplexedProcessor.h +++ b/lib/cpp/src/thrift/processor/TMultiplexedProcessor.h @@ -27,7 +27,7 @@ namespace apache { namespace thrift { -using boost::shared_ptr; +using stdcxx::shared_ptr; namespace protocol { diff --git a/lib/cpp/src/thrift/protocol/TBinaryProtocol.h b/lib/cpp/src/thrift/protocol/TBinaryProtocol.h index 87c53f78e..f28d27872 100644 --- a/lib/cpp/src/thrift/protocol/TBinaryProtocol.h +++ b/lib/cpp/src/thrift/protocol/TBinaryProtocol.h @@ -23,7 +23,7 @@ #include <thrift/protocol/TProtocol.h> #include <thrift/protocol/TVirtualProtocol.h> -#include <boost/shared_ptr.hpp> +#include <thrift/stdcxx.h> namespace apache { namespace thrift { @@ -41,7 +41,7 @@ public: static const int32_t VERSION_1 = ((int32_t)0x80010000); // VERSION_2 (0x80020000) was taken by TDenseProtocol (which has since been removed) - TBinaryProtocolT(boost::shared_ptr<Transport_> trans) + TBinaryProtocolT(stdcxx::shared_ptr<Transport_> trans) : TVirtualProtocol<TBinaryProtocolT<Transport_, ByteOrder_> >(trans), trans_(trans.get()), string_limit_(0), @@ -49,7 +49,7 @@ public: strict_read_(false), strict_write_(true) {} - TBinaryProtocolT(boost::shared_ptr<Transport_> trans, + TBinaryProtocolT(stdcxx::shared_ptr<Transport_> trans, int32_t string_limit, int32_t container_limit, bool strict_read, @@ -212,8 +212,8 @@ public: strict_write_ = strict_write; } - boost::shared_ptr<TProtocol> getProtocol(boost::shared_ptr<TTransport> trans) { - boost::shared_ptr<Transport_> specific_trans = boost::dynamic_pointer_cast<Transport_>(trans); + stdcxx::shared_ptr<TProtocol> getProtocol(stdcxx::shared_ptr<TTransport> trans) { + stdcxx::shared_ptr<Transport_> specific_trans = stdcxx::dynamic_pointer_cast<Transport_>(trans); TProtocol* prot; if (specific_trans) { prot = new TBinaryProtocolT<Transport_, ByteOrder_>(specific_trans, @@ -229,7 +229,7 @@ public: strict_write_); } - return boost::shared_ptr<TProtocol>(prot); + return stdcxx::shared_ptr<TProtocol>(prot); } private: diff --git a/lib/cpp/src/thrift/protocol/TCompactProtocol.h b/lib/cpp/src/thrift/protocol/TCompactProtocol.h index d970be27c..e6024a9d3 100644 --- a/lib/cpp/src/thrift/protocol/TCompactProtocol.h +++ b/lib/cpp/src/thrift/protocol/TCompactProtocol.h @@ -23,7 +23,7 @@ #include <thrift/protocol/TVirtualProtocol.h> #include <stack> -#include <boost/shared_ptr.hpp> +#include <thrift/stdcxx.h> namespace apache { namespace thrift { @@ -74,7 +74,7 @@ protected: int16_t lastFieldId_; public: - TCompactProtocolT(boost::shared_ptr<Transport_> trans) + TCompactProtocolT(stdcxx::shared_ptr<Transport_> trans) : TVirtualProtocol<TCompactProtocolT<Transport_> >(trans), trans_(trans.get()), lastFieldId_(0), @@ -86,7 +86,7 @@ public: boolValue_.hasBoolValue = false; } - TCompactProtocolT(boost::shared_ptr<Transport_> trans, + TCompactProtocolT(stdcxx::shared_ptr<Transport_> trans, int32_t string_limit, int32_t container_limit) : TVirtualProtocol<TCompactProtocolT<Transport_> >(trans), @@ -239,8 +239,8 @@ public: void setContainerSizeLimit(int32_t container_limit) { container_limit_ = container_limit; } - boost::shared_ptr<TProtocol> getProtocol(boost::shared_ptr<TTransport> trans) { - boost::shared_ptr<Transport_> specific_trans = boost::dynamic_pointer_cast<Transport_>(trans); + stdcxx::shared_ptr<TProtocol> getProtocol(stdcxx::shared_ptr<TTransport> trans) { + stdcxx::shared_ptr<Transport_> specific_trans = stdcxx::dynamic_pointer_cast<Transport_>(trans); TProtocol* prot; if (specific_trans) { prot = new TCompactProtocolT<Transport_>(specific_trans, string_limit_, container_limit_); @@ -248,7 +248,7 @@ public: prot = new TCompactProtocol(trans, string_limit_, container_limit_); } - return boost::shared_ptr<TProtocol>(prot); + return stdcxx::shared_ptr<TProtocol>(prot); } private: diff --git a/lib/cpp/src/thrift/protocol/TDebugProtocol.h b/lib/cpp/src/thrift/protocol/TDebugProtocol.h index cc9323026..301d05aa4 100644 --- a/lib/cpp/src/thrift/protocol/TDebugProtocol.h +++ b/lib/cpp/src/thrift/protocol/TDebugProtocol.h @@ -22,7 +22,7 @@ #include <thrift/protocol/TVirtualProtocol.h> -#include <boost/shared_ptr.hpp> +#include <thrift/stdcxx.h> namespace apache { namespace thrift { @@ -51,7 +51,7 @@ private: enum write_state_t { UNINIT, STRUCT, LIST, SET, MAP_KEY, MAP_VALUE }; public: - TDebugProtocol(boost::shared_ptr<TTransport> trans) + TDebugProtocol(stdcxx::shared_ptr<TTransport> trans) : TVirtualProtocol<TDebugProtocol>(trans), trans_(trans.get()), string_limit_(DEFAULT_STRING_LIMIT), @@ -141,8 +141,8 @@ public: TDebugProtocolFactory() {} virtual ~TDebugProtocolFactory() {} - boost::shared_ptr<TProtocol> getProtocol(boost::shared_ptr<TTransport> trans) { - return boost::shared_ptr<TProtocol>(new TDebugProtocol(trans)); + stdcxx::shared_ptr<TProtocol> getProtocol(stdcxx::shared_ptr<TTransport> trans) { + return stdcxx::shared_ptr<TProtocol>(new TDebugProtocol(trans)); } }; } @@ -160,7 +160,7 @@ std::string ThriftDebugString(const ThriftStruct& ts) { using namespace apache::thrift::transport; using namespace apache::thrift::protocol; TMemoryBuffer* buffer = new TMemoryBuffer; - boost::shared_ptr<TTransport> trans(buffer); + stdcxx::shared_ptr<TTransport> trans(buffer); TDebugProtocol protocol(trans); ts.write(&protocol); @@ -178,7 +178,7 @@ std::string DebugString(const std::vector<Object>& vec) { using namespace apache::thrift::transport; using namespace apache::thrift::protocol; TMemoryBuffer* buffer = new TMemoryBuffer; - boost::shared_ptr<TTransport> trans(buffer); + stdcxx::shared_ptr<TTransport> trans(buffer); TDebugProtocol protocol(trans); // I am gross! diff --git a/lib/cpp/src/thrift/protocol/THeaderProtocol.cpp b/lib/cpp/src/thrift/protocol/THeaderProtocol.cpp index 02dc7362e..26676172f 100644 --- a/lib/cpp/src/thrift/protocol/THeaderProtocol.cpp +++ b/lib/cpp/src/thrift/protocol/THeaderProtocol.cpp @@ -27,7 +27,7 @@ #include <limits> #include <boost/static_assert.hpp> -#include <boost/make_shared.hpp> +#include <thrift/stdcxx.h> namespace apache { namespace thrift { @@ -42,11 +42,11 @@ void THeaderProtocol::resetProtocol() { switch (protoId_) { case T_BINARY_PROTOCOL: - proto_ = boost::make_shared<TBinaryProtocolT<THeaderTransport> >(trans_); + proto_ = stdcxx::make_shared<TBinaryProtocolT<THeaderTransport> >(trans_); break; case T_COMPACT_PROTOCOL: - proto_ = boost::make_shared<TCompactProtocolT<THeaderTransport> >(trans_); + proto_ = stdcxx::make_shared<TCompactProtocolT<THeaderTransport> >(trans_); break; default: diff --git a/lib/cpp/src/thrift/protocol/THeaderProtocol.h b/lib/cpp/src/thrift/protocol/THeaderProtocol.h index b01bfb6f1..0b3997cf6 100644 --- a/lib/cpp/src/thrift/protocol/THeaderProtocol.h +++ b/lib/cpp/src/thrift/protocol/THeaderProtocol.h @@ -25,7 +25,7 @@ #include <thrift/protocol/TVirtualProtocol.h> #include <thrift/transport/THeaderTransport.h> -#include <boost/shared_ptr.hpp> +#include <thrift/stdcxx.h> using apache::thrift::transport::THeaderTransport; @@ -43,21 +43,21 @@ protected: public: void resetProtocol(); - explicit THeaderProtocol(const boost::shared_ptr<TTransport>& trans, + explicit THeaderProtocol(const stdcxx::shared_ptr<TTransport>& trans, uint16_t protoId = T_COMPACT_PROTOCOL) - : TVirtualProtocol<THeaderProtocol>(boost::shared_ptr<TTransport>(new THeaderTransport(trans))), - trans_(boost::dynamic_pointer_cast<THeaderTransport>(getTransport())), + : TVirtualProtocol<THeaderProtocol>(stdcxx::shared_ptr<TTransport>(new THeaderTransport(trans))), + trans_(stdcxx::dynamic_pointer_cast<THeaderTransport>(getTransport())), protoId_(protoId) { trans_->setProtocolId(protoId); resetProtocol(); } - THeaderProtocol(const boost::shared_ptr<TTransport>& inTrans, - const boost::shared_ptr<TTransport>& outTrans, + THeaderProtocol(const stdcxx::shared_ptr<TTransport>& inTrans, + const stdcxx::shared_ptr<TTransport>& outTrans, uint16_t protoId = T_COMPACT_PROTOCOL) : TVirtualProtocol<THeaderProtocol>( - boost::shared_ptr<TTransport>(new THeaderTransport(inTrans, outTrans))), - trans_(boost::dynamic_pointer_cast<THeaderTransport>(getTransport())), + stdcxx::shared_ptr<TTransport>(new THeaderTransport(inTrans, outTrans))), + trans_(stdcxx::dynamic_pointer_cast<THeaderTransport>(getTransport())), protoId_(protoId) { trans_->setProtocolId(protoId); resetProtocol(); @@ -182,25 +182,25 @@ public: uint32_t readBinary(std::string& binary); protected: - boost::shared_ptr<THeaderTransport> trans_; + stdcxx::shared_ptr<THeaderTransport> trans_; - boost::shared_ptr<TProtocol> proto_; + stdcxx::shared_ptr<TProtocol> proto_; uint32_t protoId_; }; class THeaderProtocolFactory : public TProtocolFactory { public: - virtual boost::shared_ptr<TProtocol> getProtocol(boost::shared_ptr<transport::TTransport> trans) { + virtual stdcxx::shared_ptr<TProtocol> getProtocol(stdcxx::shared_ptr<transport::TTransport> trans) { THeaderProtocol* headerProtocol - = new THeaderProtocol(trans, boost::shared_ptr<transport::TTransport>(), T_BINARY_PROTOCOL); - return boost::shared_ptr<TProtocol>(headerProtocol); + = new THeaderProtocol(trans, stdcxx::shared_ptr<transport::TTransport>(), T_BINARY_PROTOCOL); + return stdcxx::shared_ptr<TProtocol>(headerProtocol); } - virtual boost::shared_ptr<TProtocol> getProtocol( - boost::shared_ptr<transport::TTransport> inTrans, - boost::shared_ptr<transport::TTransport> outTrans) { + virtual stdcxx::shared_ptr<TProtocol> getProtocol( + stdcxx::shared_ptr<transport::TTransport> inTrans, + stdcxx::shared_ptr<transport::TTransport> outTrans) { THeaderProtocol* headerProtocol = new THeaderProtocol(inTrans, outTrans, T_BINARY_PROTOCOL); - return boost::shared_ptr<TProtocol>(headerProtocol); + return stdcxx::shared_ptr<TProtocol>(headerProtocol); } }; } diff --git a/lib/cpp/src/thrift/protocol/TJSONProtocol.cpp b/lib/cpp/src/thrift/protocol/TJSONProtocol.cpp index 943d9602e..bbba2604e 100644 --- a/lib/cpp/src/thrift/protocol/TJSONProtocol.cpp +++ b/lib/cpp/src/thrift/protocol/TJSONProtocol.cpp @@ -398,7 +398,7 @@ private: bool first_; }; -TJSONProtocol::TJSONProtocol(boost::shared_ptr<TTransport> ptrans) +TJSONProtocol::TJSONProtocol(stdcxx::shared_ptr<TTransport> ptrans) : TVirtualProtocol<TJSONProtocol>(ptrans), trans_(ptrans.get()), context_(new TJSONContext()), @@ -408,7 +408,7 @@ TJSONProtocol::TJSONProtocol(boost::shared_ptr<TTransport> ptrans) TJSONProtocol::~TJSONProtocol() { } -void TJSONProtocol::pushContext(boost::shared_ptr<TJSONContext> c) { +void TJSONProtocol::pushContext(stdcxx::shared_ptr<TJSONContext> c) { contexts_.push(context_); context_ = c; } @@ -576,7 +576,7 @@ uint32_t TJSONProtocol::writeJSONDouble(double num) { uint32_t TJSONProtocol::writeJSONObjectStart() { uint32_t result = context_->write(*trans_); trans_->write(&kJSONObjectStart, 1); - pushContext(boost::shared_ptr<TJSONContext>(new JSONPairContext())); + pushContext(stdcxx::shared_ptr<TJSONContext>(new JSONPairContext())); return result + 1; } @@ -589,7 +589,7 @@ uint32_t TJSONProtocol::writeJSONObjectEnd() { uint32_t TJSONProtocol::writeJSONArrayStart() { uint32_t result = context_->write(*trans_); trans_->write(&kJSONArrayStart, 1); - pushContext(boost::shared_ptr<TJSONContext>(new JSONListContext())); + pushContext(stdcxx::shared_ptr<TJSONContext>(new JSONListContext())); return result + 1; } @@ -923,7 +923,7 @@ uint32_t TJSONProtocol::readJSONDouble(double& num) { uint32_t TJSONProtocol::readJSONObjectStart() { uint32_t result = context_->read(reader_); result += readJSONSyntaxChar(kJSONObjectStart); - pushContext(boost::shared_ptr<TJSONContext>(new JSONPairContext())); + pushContext(stdcxx::shared_ptr<TJSONContext>(new JSONPairContext())); return result; } @@ -936,7 +936,7 @@ uint32_t TJSONProtocol::readJSONObjectEnd() { uint32_t TJSONProtocol::readJSONArrayStart() { uint32_t result = context_->read(reader_); result += readJSONSyntaxChar(kJSONArrayStart); - pushContext(boost::shared_ptr<TJSONContext>(new JSONListContext())); + pushContext(stdcxx::shared_ptr<TJSONContext>(new JSONListContext())); return result; } diff --git a/lib/cpp/src/thrift/protocol/TJSONProtocol.h b/lib/cpp/src/thrift/protocol/TJSONProtocol.h index 5a94624f3..16dff561c 100644 --- a/lib/cpp/src/thrift/protocol/TJSONProtocol.h +++ b/lib/cpp/src/thrift/protocol/TJSONProtocol.h @@ -96,12 +96,12 @@ class TJSONContext; */ class TJSONProtocol : public TVirtualProtocol<TJSONProtocol> { public: - TJSONProtocol(boost::shared_ptr<TTransport> ptrans); + TJSONProtocol(stdcxx::shared_ptr<TTransport> ptrans); ~TJSONProtocol(); private: - void pushContext(boost::shared_ptr<TJSONContext> c); + void pushContext(stdcxx::shared_ptr<TJSONContext> c); void popContext(); @@ -276,8 +276,8 @@ public: private: TTransport* trans_; - std::stack<boost::shared_ptr<TJSONContext> > contexts_; - boost::shared_ptr<TJSONContext> context_; + std::stack<stdcxx::shared_ptr<TJSONContext> > contexts_; + stdcxx::shared_ptr<TJSONContext> context_; LookaheadReader reader_; }; @@ -290,8 +290,8 @@ public: virtual ~TJSONProtocolFactory() {} - boost::shared_ptr<TProtocol> getProtocol(boost::shared_ptr<TTransport> trans) { - return boost::shared_ptr<TProtocol>(new TJSONProtocol(trans)); + stdcxx::shared_ptr<TProtocol> getProtocol(stdcxx::shared_ptr<TTransport> trans) { + return stdcxx::shared_ptr<TProtocol>(new TJSONProtocol(trans)); } }; } @@ -309,7 +309,7 @@ std::string ThriftJSONString(const ThriftStruct& ts) { using namespace apache::thrift::transport; using namespace apache::thrift::protocol; TMemoryBuffer* buffer = new TMemoryBuffer; - boost::shared_ptr<TTransport> trans(buffer); + stdcxx::shared_ptr<TTransport> trans(buffer); TJSONProtocol protocol(trans); ts.write(&protocol); diff --git a/lib/cpp/src/thrift/protocol/TMultiplexedProtocol.h b/lib/cpp/src/thrift/protocol/TMultiplexedProtocol.h index 0244fbeab..dd7e88ffc 100644 --- a/lib/cpp/src/thrift/protocol/TMultiplexedProtocol.h +++ b/lib/cpp/src/thrift/protocol/TMultiplexedProtocol.h @@ -25,7 +25,7 @@ namespace apache { namespace thrift { namespace protocol { -using boost::shared_ptr; +using stdcxx::shared_ptr; /** * <code>TMultiplexedProtocol</code> is a protocol-independent concrete decorator diff --git a/lib/cpp/src/thrift/protocol/TProtocol.h b/lib/cpp/src/thrift/protocol/TProtocol.h index 276cefaea..2a9d07bad 100644 --- a/lib/cpp/src/thrift/protocol/TProtocol.h +++ b/lib/cpp/src/thrift/protocol/TProtocol.h @@ -28,7 +28,7 @@ #include <thrift/transport/TTransport.h> #include <thrift/protocol/TProtocolException.h> -#include <boost/shared_ptr.hpp> +#include <thrift/stdcxx.h> #include <boost/static_assert.hpp> #ifdef HAVE_NETINET_IN_H @@ -550,12 +550,12 @@ public: } virtual uint32_t skip_virt(TType type); - inline boost::shared_ptr<TTransport> getTransport() { return ptrans_; } + inline stdcxx::shared_ptr<TTransport> getTransport() { return ptrans_; } // TODO: remove these two calls, they are for backwards // compatibility - inline boost::shared_ptr<TTransport> getInputTransport() { return ptrans_; } - inline boost::shared_ptr<TTransport> getOutputTransport() { return ptrans_; } + inline stdcxx::shared_ptr<TTransport> getInputTransport() { return ptrans_; } + inline stdcxx::shared_ptr<TTransport> getOutputTransport() { return ptrans_; } // input and output recursion depth are kept separate so that one protocol // can be used concurrently for both input and output. @@ -577,11 +577,11 @@ public: void setRecurisionLimit(uint32_t depth) {recursion_limit_ = depth;} protected: - TProtocol(boost::shared_ptr<TTransport> ptrans) + TProtocol(stdcxx::shared_ptr<TTransport> ptrans) : ptrans_(ptrans), input_recursion_depth_(0), output_recursion_depth_(0), recursion_limit_(DEFAULT_RECURSION_LIMIT) {} - boost::shared_ptr<TTransport> ptrans_; + stdcxx::shared_ptr<TTransport> ptrans_; private: TProtocol() {} @@ -599,9 +599,9 @@ public: virtual ~TProtocolFactory(); - virtual boost::shared_ptr<TProtocol> getProtocol(boost::shared_ptr<TTransport> trans) = 0; - virtual boost::shared_ptr<TProtocol> getProtocol(boost::shared_ptr<TTransport> inTrans, - boost::shared_ptr<TTransport> outTrans) { + virtual stdcxx::shared_ptr<TProtocol> getProtocol(stdcxx::shared_ptr<TTransport> trans) = 0; + virtual stdcxx::shared_ptr<TProtocol> getProtocol(stdcxx::shared_ptr<TTransport> inTrans, + stdcxx::shared_ptr<TTransport> outTrans) { (void)outTrans; return getProtocol(inTrans); } diff --git a/lib/cpp/src/thrift/protocol/TProtocolDecorator.h b/lib/cpp/src/thrift/protocol/TProtocolDecorator.h index 446a81f83..a353b7968 100644 --- a/lib/cpp/src/thrift/protocol/TProtocolDecorator.h +++ b/lib/cpp/src/thrift/protocol/TProtocolDecorator.h @@ -21,12 +21,12 @@ #define THRIFT_TPROTOCOLDECORATOR_H_ 1 #include <thrift/protocol/TProtocol.h> -#include <boost/shared_ptr.hpp> +#include <thrift/stdcxx.h> namespace apache { namespace thrift { namespace protocol { -using boost::shared_ptr; +using stdcxx::shared_ptr; /** * <code>TProtocolDecorator</code> forwards all requests to an enclosed diff --git a/lib/cpp/src/thrift/protocol/TProtocolTap.h b/lib/cpp/src/thrift/protocol/TProtocolTap.h index 3e563934e..176d4fdc0 100644 --- a/lib/cpp/src/thrift/protocol/TProtocolTap.h +++ b/lib/cpp/src/thrift/protocol/TProtocolTap.h @@ -36,7 +36,7 @@ using apache::thrift::transport::TTransport; */ class TProtocolTap : public TVirtualProtocol<TProtocolTap> { public: - TProtocolTap(boost::shared_ptr<TProtocol> source, boost::shared_ptr<TProtocol> sink) + TProtocolTap(stdcxx::shared_ptr<TProtocol> source, stdcxx::shared_ptr<TProtocol> sink) : TVirtualProtocol<TProtocolTap>(source->getTransport()), source_(source), sink_(sink) {} uint32_t readMessageBegin(std::string& name, TMessageType& messageType, int32_t& seqid) { @@ -167,8 +167,8 @@ public: } private: - boost::shared_ptr<TProtocol> source_; - boost::shared_ptr<TProtocol> sink_; + stdcxx::shared_ptr<TProtocol> source_; + stdcxx::shared_ptr<TProtocol> sink_; }; } } diff --git a/lib/cpp/src/thrift/protocol/TVirtualProtocol.h b/lib/cpp/src/thrift/protocol/TVirtualProtocol.h index 831c3a259..628b494a4 100644 --- a/lib/cpp/src/thrift/protocol/TVirtualProtocol.h +++ b/lib/cpp/src/thrift/protocol/TVirtualProtocol.h @@ -301,7 +301,7 @@ public: uint32_t skip(TType type) { return ::apache::thrift::protocol::skip(*this, type); } protected: - TProtocolDefaults(boost::shared_ptr<TTransport> ptrans) : TProtocol(ptrans) {} + TProtocolDefaults(stdcxx::shared_ptr<TTransport> ptrans) : TProtocol(ptrans) {} }; /** @@ -504,7 +504,7 @@ public: using Super_::readBool; // so we don't hide readBool(bool&) protected: - TVirtualProtocol(boost::shared_ptr<TTransport> ptrans) : Super_(ptrans) {} + TVirtualProtocol(stdcxx::shared_ptr<TTransport> ptrans) : Super_(ptrans) {} }; } } diff --git a/lib/cpp/src/thrift/qt/TQIODeviceTransport.cpp b/lib/cpp/src/thrift/qt/TQIODeviceTransport.cpp index 686f24297..cd38b0125 100644 --- a/lib/cpp/src/thrift/qt/TQIODeviceTransport.cpp +++ b/lib/cpp/src/thrift/qt/TQIODeviceTransport.cpp @@ -23,11 +23,13 @@ #include <QIODevice> #include <thrift/transport/TBufferTransports.h> - -using boost::shared_ptr; +#include <thrift/stdcxx.h> namespace apache { namespace thrift { + +using stdcxx::shared_ptr; + namespace transport { TQIODeviceTransport::TQIODeviceTransport(shared_ptr<QIODevice> dev) : dev_(dev) { diff --git a/lib/cpp/src/thrift/qt/TQIODeviceTransport.h b/lib/cpp/src/thrift/qt/TQIODeviceTransport.h index 8091d3287..9087f2c41 100644 --- a/lib/cpp/src/thrift/qt/TQIODeviceTransport.h +++ b/lib/cpp/src/thrift/qt/TQIODeviceTransport.h @@ -20,7 +20,7 @@ #ifndef _THRIFT_ASYNC_TQIODEVICE_TRANSPORT_H_ #define _THRIFT_ASYNC_TQIODEVICE_TRANSPORT_H_ 1 -#include <boost/shared_ptr.hpp> +#include <thrift/stdcxx.h> #include <thrift/transport/TVirtualTransport.h> @@ -36,7 +36,7 @@ namespace transport { class TQIODeviceTransport : public apache::thrift::transport::TVirtualTransport<TQIODeviceTransport> { public: - explicit TQIODeviceTransport(boost::shared_ptr<QIODevice> dev); + explicit TQIODeviceTransport(stdcxx::shared_ptr<QIODevice> dev); virtual ~TQIODeviceTransport(); void open(); @@ -59,7 +59,7 @@ private: TQIODeviceTransport(const TQIODeviceTransport&); TQIODeviceTransport& operator=(const TQIODeviceTransport&); - boost::shared_ptr<QIODevice> dev_; + stdcxx::shared_ptr<QIODevice> dev_; }; } } diff --git a/lib/cpp/src/thrift/qt/TQTcpServer.cpp b/lib/cpp/src/thrift/qt/TQTcpServer.cpp index 350198c88..c4669d782 100644 --- a/lib/cpp/src/thrift/qt/TQTcpServer.cpp +++ b/lib/cpp/src/thrift/qt/TQTcpServer.cpp @@ -23,19 +23,20 @@ #include <QMetaType> #include <QTcpSocket> -#include <thrift/cxxfunctional.h> +#include <thrift/stdcxx.h> #include <thrift/protocol/TProtocol.h> #include <thrift/async/TAsyncProcessor.h> -using boost::shared_ptr; using apache::thrift::protocol::TProtocol; using apache::thrift::protocol::TProtocolFactory; using apache::thrift::transport::TTransport; using apache::thrift::transport::TTransportException; using apache::thrift::transport::TQIODeviceTransport; -using apache::thrift::stdcxx::function; using apache::thrift::stdcxx::bind; +using apache::thrift::stdcxx::function; +using apache::thrift::stdcxx::placeholders::_1; +using apache::thrift::stdcxx::shared_ptr; QT_USE_NAMESPACE @@ -110,7 +111,7 @@ void TQTcpServer::beginDecode() { try { processor_ - ->process(bind(&TQTcpServer::finish, this, ctx, apache::thrift::stdcxx::placeholders::_1), + ->process(bind(&TQTcpServer::finish, this, ctx, _1), ctx->iprot_, ctx->oprot_); } catch (const TTransportException& ex) { diff --git a/lib/cpp/src/thrift/qt/TQTcpServer.h b/lib/cpp/src/thrift/qt/TQTcpServer.h index 081d84afe..0d32afa0a 100644 --- a/lib/cpp/src/thrift/qt/TQTcpServer.h +++ b/lib/cpp/src/thrift/qt/TQTcpServer.h @@ -23,7 +23,7 @@ #include <QObject> #include <QTcpServer> -#include <boost/shared_ptr.hpp> +#include <thrift/stdcxx.h> namespace apache { namespace thrift { @@ -47,9 +47,9 @@ class TAsyncProcessor; class TQTcpServer : public QObject { Q_OBJECT public: - TQTcpServer(boost::shared_ptr<QTcpServer> server, - boost::shared_ptr<TAsyncProcessor> processor, - boost::shared_ptr<apache::thrift::protocol::TProtocolFactory> protocolFactory, + TQTcpServer(stdcxx::shared_ptr<QTcpServer> server, + stdcxx::shared_ptr<TAsyncProcessor> processor, + stdcxx::shared_ptr<apache::thrift::protocol::TProtocolFactory> protocolFactory, QObject* parent = NULL); virtual ~TQTcpServer(); @@ -65,13 +65,13 @@ private: struct ConnectionContext; void scheduleDeleteConnectionContext(QTcpSocket* connection); - void finish(boost::shared_ptr<ConnectionContext> ctx, bool healthy); + void finish(stdcxx::shared_ptr<ConnectionContext> ctx, bool healthy); - boost::shared_ptr<QTcpServer> server_; - boost::shared_ptr<TAsyncProcessor> processor_; - boost::shared_ptr<apache::thrift::protocol::TProtocolFactory> pfact_; + stdcxx::shared_ptr<QTcpServer> server_; + stdcxx::shared_ptr<TAsyncProcessor> processor_; + stdcxx::shared_ptr<apache::thrift::protocol::TProtocolFactory> pfact_; - typedef std::map<QTcpSocket*, boost::shared_ptr<ConnectionContext> > ConnectionContextMap; + typedef std::map<QTcpSocket*, stdcxx::shared_ptr<ConnectionContext> > ConnectionContextMap; ConnectionContextMap ctxMap_; }; } diff --git a/lib/cpp/src/thrift/server/TConnectedClient.cpp b/lib/cpp/src/thrift/server/TConnectedClient.cpp index 889c885c9..33ec3a980 100644 --- a/lib/cpp/src/thrift/server/TConnectedClient.cpp +++ b/lib/cpp/src/thrift/server/TConnectedClient.cpp @@ -28,7 +28,7 @@ using apache::thrift::protocol::TProtocol; using apache::thrift::server::TServerEventHandler; using apache::thrift::transport::TTransport; using apache::thrift::transport::TTransportException; -using boost::shared_ptr; +using stdcxx::shared_ptr; using std::string; TConnectedClient::TConnectedClient(const shared_ptr<TProcessor>& processor, diff --git a/lib/cpp/src/thrift/server/TConnectedClient.h b/lib/cpp/src/thrift/server/TConnectedClient.h index 3ea065e82..2f9d4c9de 100644 --- a/lib/cpp/src/thrift/server/TConnectedClient.h +++ b/lib/cpp/src/thrift/server/TConnectedClient.h @@ -20,7 +20,7 @@ #ifndef _THRIFT_SERVER_TCONNECTEDCLIENT_H_ #define _THRIFT_SERVER_TCONNECTEDCLIENT_H_ 1 -#include <boost/shared_ptr.hpp> +#include <thrift/stdcxx.h> #include <thrift/TProcessor.h> #include <thrift/protocol/TProtocol.h> #include <thrift/server/TServer.h> @@ -49,11 +49,11 @@ public: * @param[in] client the TTransport representing the client */ TConnectedClient( - const boost::shared_ptr<apache::thrift::TProcessor>& processor, - const boost::shared_ptr<apache::thrift::protocol::TProtocol>& inputProtocol, - const boost::shared_ptr<apache::thrift::protocol::TProtocol>& outputProtocol, - const boost::shared_ptr<apache::thrift::server::TServerEventHandler>& eventHandler, - const boost::shared_ptr<apache::thrift::transport::TTransport>& client); + const stdcxx::shared_ptr<apache::thrift::TProcessor>& processor, + const stdcxx::shared_ptr<apache::thrift::protocol::TProtocol>& inputProtocol, + const stdcxx::shared_ptr<apache::thrift::protocol::TProtocol>& outputProtocol, + const stdcxx::shared_ptr<apache::thrift::server::TServerEventHandler>& eventHandler, + const stdcxx::shared_ptr<apache::thrift::transport::TTransport>& client); /** * Destructor. @@ -92,11 +92,11 @@ protected: virtual void cleanup(); private: - boost::shared_ptr<apache::thrift::TProcessor> processor_; - boost::shared_ptr<apache::thrift::protocol::TProtocol> inputProtocol_; - boost::shared_ptr<apache::thrift::protocol::TProtocol> outputProtocol_; - boost::shared_ptr<apache::thrift::server::TServerEventHandler> eventHandler_; - boost::shared_ptr<apache::thrift::transport::TTransport> client_; + stdcxx::shared_ptr<apache::thrift::TProcessor> processor_; + stdcxx::shared_ptr<apache::thrift::protocol::TProtocol> inputProtocol_; + stdcxx::shared_ptr<apache::thrift::protocol::TProtocol> outputProtocol_; + stdcxx::shared_ptr<apache::thrift::server::TServerEventHandler> eventHandler_; + stdcxx::shared_ptr<apache::thrift::transport::TTransport> client_; /** * Context acquired from the eventHandler_ if one exists. diff --git a/lib/cpp/src/thrift/server/TNonblockingServer.cpp b/lib/cpp/src/thrift/server/TNonblockingServer.cpp index d5af12a6f..d17f77c19 100644 --- a/lib/cpp/src/thrift/server/TNonblockingServer.cpp +++ b/lib/cpp/src/thrift/server/TNonblockingServer.cpp @@ -25,6 +25,7 @@ #include <thrift/concurrency/PlatformThreadFactory.h> #include <thrift/transport/PlatformSocket.h> +#include <algorithm> #include <iostream> #ifdef HAVE_SYS_SELECT_H @@ -77,10 +78,9 @@ namespace server { using namespace apache::thrift::protocol; using namespace apache::thrift::transport; using namespace apache::thrift::concurrency; -using namespace std; using apache::thrift::transport::TSocket; using apache::thrift::transport::TTransportException; -using boost::shared_ptr; +using stdcxx::shared_ptr; /// Three states for sockets: recv frame size, recv data, and send mode enum TSocketState { SOCKET_RECV_FRAMING, SOCKET_RECV, SOCKET_SEND }; @@ -115,10 +115,10 @@ private: TNonblockingServer* server_; /// TProcessor - boost::shared_ptr<TProcessor> processor_; + stdcxx::shared_ptr<TProcessor> processor_; /// Object wrapping network socket - boost::shared_ptr<TSocket> tSocket_; + stdcxx::shared_ptr<TSocket> tSocket_; /// Libevent object struct event event_; @@ -160,23 +160,23 @@ private: int32_t callsForResize_; /// Transport to read from - boost::shared_ptr<TMemoryBuffer> inputTransport_; + stdcxx::shared_ptr<TMemoryBuffer> inputTransport_; /// Transport that processor writes to - boost::shared_ptr<TMemoryBuffer> outputTransport_; + stdcxx::shared_ptr<TMemoryBuffer> outputTransport_; /// extra transport generated by transport factory (e.g. BufferedRouterTransport) - boost::shared_ptr<TTransport> factoryInputTransport_; - boost::shared_ptr<TTransport> factoryOutputTransport_; + stdcxx::shared_ptr<TTransport> factoryInputTransport_; + stdcxx::shared_ptr<TTransport> factoryOutputTransport_; /// Protocol decoder - boost::shared_ptr<TProtocol> inputProtocol_; + stdcxx::shared_ptr<TProtocol> inputProtocol_; /// Protocol encoder - boost::shared_ptr<TProtocol> outputProtocol_; + stdcxx::shared_ptr<TProtocol> outputProtocol_; /// Server event handler, if any - boost::shared_ptr<TServerEventHandler> serverEventHandler_; + stdcxx::shared_ptr<TServerEventHandler> serverEventHandler_; /// Thrift call context, if any void* connectionContext_; @@ -209,7 +209,7 @@ public: class Task; /// Constructor - TConnection(boost::shared_ptr<TSocket> socket, + TConnection(stdcxx::shared_ptr<TSocket> socket, TNonblockingIOThread* ioThread) { readBuffer_ = NULL; readBufferSize_ = 0; @@ -245,7 +245,7 @@ public: void init(TNonblockingIOThread* ioThread); /// set socket for connection - void setSocket(boost::shared_ptr<TSocket> socket); + void setSocket(stdcxx::shared_ptr<TSocket> socket); /** * This is called when the application transitions from one state into @@ -301,10 +301,10 @@ public: TAppState getState() const { return appState_; } /// return the TSocket transport wrapping this network connection - boost::shared_ptr<TSocket> getTSocket() const { return tSocket_; } + stdcxx::shared_ptr<TSocket> getTSocket() const { return tSocket_; } /// return the server event handler if any - boost::shared_ptr<TServerEventHandler> getServerEventHandler() { return serverEventHandler_; } + stdcxx::shared_ptr<TServerEventHandler> getServerEventHandler() { return serverEventHandler_; } /// return the Thrift connection context if any void* getConnectionContext() { return connectionContext_; } @@ -312,9 +312,9 @@ public: class TNonblockingServer::TConnection::Task : public Runnable { public: - Task(boost::shared_ptr<TProcessor> processor, - boost::shared_ptr<TProtocol> input, - boost::shared_ptr<TProtocol> output, + Task(stdcxx::shared_ptr<TProcessor> processor, + stdcxx::shared_ptr<TProtocol> input, + stdcxx::shared_ptr<TProtocol> output, TConnection* connection) : processor_(processor), input_(input), @@ -336,7 +336,7 @@ public: } } catch (const TTransportException& ttx) { GlobalOutput.printf("TNonblockingServer: client died: %s", ttx.what()); - } catch (const bad_alloc&) { + } catch (const std::bad_alloc&) { GlobalOutput("TNonblockingServer: caught bad_alloc exception."); exit(1); } catch (const std::exception& x) { @@ -359,11 +359,11 @@ public: TConnection* getTConnection() { return connection_; } private: - boost::shared_ptr<TProcessor> processor_; - boost::shared_ptr<TProtocol> input_; - boost::shared_ptr<TProtocol> output_; + stdcxx::shared_ptr<TProcessor> processor_; + stdcxx::shared_ptr<TProtocol> input_; + stdcxx::shared_ptr<TProtocol> output_; TConnection* connection_; - boost::shared_ptr<TServerEventHandler> serverEventHandler_; + stdcxx::shared_ptr<TServerEventHandler> serverEventHandler_; void* connectionContext_; }; @@ -410,7 +410,7 @@ void TNonblockingServer::TConnection::init(TNonblockingIOThread* ioThread) { processor_ = server_->getProcessor(inputProtocol_, outputProtocol_, tSocket_); } -void TNonblockingServer::TConnection::setSocket(boost::shared_ptr<TSocket> socket) { +void TNonblockingServer::TConnection::setSocket(stdcxx::shared_ptr<TSocket> socket) { tSocket_ = socket; } @@ -594,7 +594,7 @@ void TNonblockingServer::TConnection::transition() { // We are setting up a Task to do this work and we will wait on it // Create task and dispatch to the thread manager - boost::shared_ptr<Runnable> task = boost::shared_ptr<Runnable>( + stdcxx::shared_ptr<Runnable> task = stdcxx::shared_ptr<Runnable>( new Task(processor_, inputProtocol_, outputProtocol_, this)); // The application is now waiting on the task to finish appState_ = APP_WAIT_TASK; @@ -879,9 +879,9 @@ TNonblockingServer::~TNonblockingServer() { // objects and the Thread objects have shared_ptrs to the TNonblockingIOThread // objects (as runnable) so these objects will never deallocate without help. while (!ioThreads_.empty()) { - boost::shared_ptr<TNonblockingIOThread> iot = ioThreads_.back(); + stdcxx::shared_ptr<TNonblockingIOThread> iot = ioThreads_.back(); ioThreads_.pop_back(); - iot->setThread(boost::shared_ptr<Thread>()); + iot->setThread(stdcxx::shared_ptr<Thread>()); } } @@ -889,7 +889,7 @@ TNonblockingServer::~TNonblockingServer() { * Creates a new connection either by reusing an object off the stack or * by allocating a new one entirely */ -TNonblockingServer::TConnection* TNonblockingServer::createConnection(boost::shared_ptr<TSocket> socket) { +TNonblockingServer::TConnection* TNonblockingServer::createConnection(stdcxx::shared_ptr<TSocket> socket) { // Check the stack Guard g(connMutex_); @@ -945,7 +945,7 @@ void TNonblockingServer::handleEvent(THRIFT_SOCKET fd, short which) { assert(fd == serverSocket_); // Going to accept a new client socket - boost::shared_ptr<TSocket> clientSocket; + stdcxx::shared_ptr<TSocket> clientSocket; clientSocket = serverTransport_->accept(); if (clientSocket) { @@ -1008,7 +1008,7 @@ void TNonblockingServer::createAndListenOnSocket() { } -void TNonblockingServer::setThreadManager(boost::shared_ptr<ThreadManager> threadManager) { +void TNonblockingServer::setThreadManager(stdcxx::shared_ptr<ThreadManager> threadManager) { threadManager_ = threadManager; if (threadManager) { threadManager->setExpireCallback( @@ -1046,7 +1046,7 @@ bool TNonblockingServer::serverOverloaded() { bool TNonblockingServer::drainPendingTask() { if (threadManager_) { - boost::shared_ptr<Runnable> task = threadManager_->removeNextPending(); + stdcxx::shared_ptr<Runnable> task = threadManager_->removeNextPending(); if (task) { TConnection* connection = static_cast<TConnection::Task*>(task.get())->getTConnection(); assert(connection && connection->getServer() && connection->getState() == APP_WAIT_TASK); @@ -1057,7 +1057,7 @@ bool TNonblockingServer::drainPendingTask() { return false; } -void TNonblockingServer::expireClose(boost::shared_ptr<Runnable> task) { +void TNonblockingServer::expireClose(stdcxx::shared_ptr<Runnable> task) { TConnection* connection = static_cast<TConnection::Task*>(task.get())->getTConnection(); assert(connection && connection->getServer() && connection->getState() == APP_WAIT_TASK); connection->forceClose(); diff --git a/lib/cpp/src/thrift/server/TNonblockingServer.h b/lib/cpp/src/thrift/server/TNonblockingServer.h index 1f60048c5..f95a72901 100644 --- a/lib/cpp/src/thrift/server/TNonblockingServer.h +++ b/lib/cpp/src/thrift/server/TNonblockingServer.h @@ -21,6 +21,7 @@ #define _THRIFT_SERVER_TNONBLOCKINGSERVER_H_ 1 #include <thrift/Thrift.h> +#include <thrift/stdcxx.h> #include <thrift/server/TServer.h> #include <thrift/transport/PlatformSocket.h> #include <thrift/transport/TBufferTransports.h> @@ -159,16 +160,16 @@ private: event_base* userEventBase_; /// For processing via thread pool, may be NULL - boost::shared_ptr<ThreadManager> threadManager_; + stdcxx::shared_ptr<ThreadManager> threadManager_; /// Is thread pool processing? bool threadPoolProcessing_; // Factory to create the IO threads - boost::shared_ptr<PlatformThreadFactory> ioThreadFactory_; + stdcxx::shared_ptr<PlatformThreadFactory> ioThreadFactory_; // Vector of IOThread objects that will handle our IO - std::vector<boost::shared_ptr<TNonblockingIOThread> > ioThreads_; + std::vector<stdcxx::shared_ptr<TNonblockingIOThread> > ioThreads_; // Index of next IO Thread to be used (for round-robin) uint32_t nextIOThread_; @@ -263,7 +264,7 @@ private: /* */ - boost::shared_ptr<TNonblockingServerTransport> serverTransport_; + stdcxx::shared_ptr<TNonblockingServerTransport> serverTransport_; /** * Called when server socket had something happen. We accept all waiting @@ -300,26 +301,25 @@ private: } public: - TNonblockingServer(const boost::shared_ptr<TProcessorFactory>& processorFactory, - const boost::shared_ptr<apache::thrift::transport::TNonblockingServerTransport>& serverTransport) + TNonblockingServer(const stdcxx::shared_ptr<TProcessorFactory>& processorFactory, + const stdcxx::shared_ptr<apache::thrift::transport::TNonblockingServerTransport>& serverTransport) : TServer(processorFactory), serverTransport_(serverTransport) { init(); } - TNonblockingServer(const boost::shared_ptr<TProcessor>& processor, - const boost::shared_ptr<apache::thrift::transport::TNonblockingServerTransport>& serverTransport) + TNonblockingServer(const stdcxx::shared_ptr<TProcessor>& processor, + const stdcxx::shared_ptr<apache::thrift::transport::TNonblockingServerTransport>& serverTransport) : TServer(processor), serverTransport_(serverTransport) { init(); } - - TNonblockingServer(const boost::shared_ptr<TProcessorFactory>& processorFactory, - const boost::shared_ptr<TProtocolFactory>& protocolFactory, - const boost::shared_ptr<apache::thrift::transport::TNonblockingServerTransport>& serverTransport, - const boost::shared_ptr<ThreadManager>& threadManager - = boost::shared_ptr<ThreadManager>()) - : TServer(processorFactory), serverTransport_(serverTransport) { + TNonblockingServer(const stdcxx::shared_ptr<TProcessorFactory>& processorFactory, + const stdcxx::shared_ptr<TProtocolFactory>& protocolFactory, + const stdcxx::shared_ptr<apache::thrift::transport::TNonblockingServerTransport>& serverTransport, + const stdcxx::shared_ptr<ThreadManager>& threadManager + = stdcxx::shared_ptr<ThreadManager>()) + : TServer(processorFactory), serverTransport_(serverTransport) { init(); setInputProtocolFactory(protocolFactory); @@ -327,14 +327,12 @@ public: setThreadManager(threadManager); } - - TNonblockingServer(const boost::shared_ptr<TProcessor>& processor, - const boost::shared_ptr<TProtocolFactory>& protocolFactory, - const boost::shared_ptr<apache::thrift::transport::TNonblockingServerTransport>& serverTransport, - const boost::shared_ptr<ThreadManager>& threadManager - = boost::shared_ptr<ThreadManager>()) + TNonblockingServer(const stdcxx::shared_ptr<TProcessor>& processor, + const stdcxx::shared_ptr<TProtocolFactory>& protocolFactory, + const stdcxx::shared_ptr<apache::thrift::transport::TNonblockingServerTransport>& serverTransport, + const stdcxx::shared_ptr<ThreadManager>& threadManager + = stdcxx::shared_ptr<ThreadManager>()) : TServer(processor), serverTransport_(serverTransport) { - init(); setInputProtocolFactory(protocolFactory); @@ -342,16 +340,15 @@ public: setThreadManager(threadManager); } - TNonblockingServer(const boost::shared_ptr<TProcessorFactory>& processorFactory, - const boost::shared_ptr<TTransportFactory>& inputTransportFactory, - const boost::shared_ptr<TTransportFactory>& outputTransportFactory, - const boost::shared_ptr<TProtocolFactory>& inputProtocolFactory, - const boost::shared_ptr<TProtocolFactory>& outputProtocolFactory, - const boost::shared_ptr<apache::thrift::transport::TNonblockingServerTransport>& serverTransport, - const boost::shared_ptr<ThreadManager>& threadManager - = boost::shared_ptr<ThreadManager>()) + TNonblockingServer(const stdcxx::shared_ptr<TProcessorFactory>& processorFactory, + const stdcxx::shared_ptr<TTransportFactory>& inputTransportFactory, + const stdcxx::shared_ptr<TTransportFactory>& outputTransportFactory, + const stdcxx::shared_ptr<TProtocolFactory>& inputProtocolFactory, + const stdcxx::shared_ptr<TProtocolFactory>& outputProtocolFactory, + const stdcxx::shared_ptr<apache::thrift::transport::TNonblockingServerTransport>& serverTransport, + const stdcxx::shared_ptr<ThreadManager>& threadManager + = stdcxx::shared_ptr<ThreadManager>()) : TServer(processorFactory), serverTransport_(serverTransport) { - init(); setInputTransportFactory(inputTransportFactory); @@ -361,16 +358,15 @@ public: setThreadManager(threadManager); } - TNonblockingServer(const boost::shared_ptr<TProcessor>& processor, - const boost::shared_ptr<TTransportFactory>& inputTransportFactory, - const boost::shared_ptr<TTransportFactory>& outputTransportFactory, - const boost::shared_ptr<TProtocolFactory>& inputProtocolFactory, - const boost::shared_ptr<TProtocolFactory>& outputProtocolFactory, - const boost::shared_ptr<apache::thrift::transport::TNonblockingServerTransport>& serverTransport, - const boost::shared_ptr<ThreadManager>& threadManager - = boost::shared_ptr<ThreadManager>()) + TNonblockingServer(const stdcxx::shared_ptr<TProcessor>& processor, + const stdcxx::shared_ptr<TTransportFactory>& inputTransportFactory, + const stdcxx::shared_ptr<TTransportFactory>& outputTransportFactory, + const stdcxx::shared_ptr<TProtocolFactory>& inputProtocolFactory, + const stdcxx::shared_ptr<TProtocolFactory>& outputProtocolFactory, + const stdcxx::shared_ptr<apache::thrift::transport::TNonblockingServerTransport>& serverTransport, + const stdcxx::shared_ptr<ThreadManager>& threadManager + = stdcxx::shared_ptr<ThreadManager>()) : TServer(processor), serverTransport_(serverTransport) { - init(); setInputTransportFactory(inputTransportFactory); @@ -382,11 +378,11 @@ public: ~TNonblockingServer(); - void setThreadManager(boost::shared_ptr<ThreadManager> threadManager); + void setThreadManager(stdcxx::shared_ptr<ThreadManager> threadManager); int getListenPort() { return serverTransport_->getListenPort(); } - boost::shared_ptr<ThreadManager> getThreadManager() { return threadManager_; } + stdcxx::shared_ptr<ThreadManager> getThreadManager() { return threadManager_; } /** * Sets the number of IO threads used by this server. Can only be used before @@ -425,7 +421,7 @@ public: bool isThreadPoolProcessing() const { return threadPoolProcessing_; } - void addTask(boost::shared_ptr<Runnable> task) { + void addTask(stdcxx::shared_ptr<Runnable> task) { threadManager_->add(task, 0LL, taskExpireTime_); } @@ -684,7 +680,7 @@ public: /// Creates a socket to listen on and binds it to the local port. void createAndListenOnSocket(); - + /** * Register the optional user-provided event-base (for single-thread servers) * @@ -713,7 +709,7 @@ private: * * @param task the runnable associated with the expired task. */ - void expireClose(boost::shared_ptr<Runnable> task); + void expireClose(stdcxx::shared_ptr<Runnable> task); /** * Return an initialized connection object. Creates or recovers from @@ -725,7 +721,7 @@ private: * @param addrLen the length of addr * @return pointer to initialized TConnection object. */ - TConnection* createConnection(boost::shared_ptr<TSocket> socket); + TConnection* createConnection(stdcxx::shared_ptr<TSocket> socket); /** * Returns a connection to pool or deletion. If the connection pool @@ -769,10 +765,10 @@ public: evutil_socket_t getNotificationRecvFD() const { return notificationPipeFDs_[0]; } // Returns the actual thread object associated with this IO thread. - boost::shared_ptr<Thread> getThread() const { return thread_; } + stdcxx::shared_ptr<Thread> getThread() const { return thread_; } // Sets the actual thread object associated with this IO thread. - void setThread(const boost::shared_ptr<Thread>& t) { thread_ = t; } + void setThread(const stdcxx::shared_ptr<Thread>& t) { thread_ = t; } // Used by TConnection objects to indicate processing has finished. bool notify(TNonblockingServer::TConnection* conn); @@ -857,7 +853,7 @@ private: evutil_socket_t notificationPipeFDs_[2]; /// Actual IO Thread - boost::shared_ptr<Thread> thread_; + stdcxx::shared_ptr<Thread> thread_; }; } } diff --git a/lib/cpp/src/thrift/server/TServer.h b/lib/cpp/src/thrift/server/TServer.h index 47e0d40b7..f4cd7bc14 100644 --- a/lib/cpp/src/thrift/server/TServer.h +++ b/lib/cpp/src/thrift/server/TServer.h @@ -25,7 +25,7 @@ #include <thrift/protocol/TBinaryProtocol.h> #include <thrift/concurrency/Thread.h> -#include <boost/shared_ptr.hpp> +#include <thrift/stdcxx.h> namespace apache { namespace thrift { @@ -58,8 +58,8 @@ public: /** * Called when a new client has connected and is about to being processing. */ - virtual void* createContext(boost::shared_ptr<TProtocol> input, - boost::shared_ptr<TProtocol> output) { + virtual void* createContext(stdcxx::shared_ptr<TProtocol> input, + stdcxx::shared_ptr<TProtocol> output) { (void)input; (void)output; return NULL; @@ -70,8 +70,8 @@ public: * context. */ virtual void deleteContext(void* serverContext, - boost::shared_ptr<TProtocol> input, - boost::shared_ptr<TProtocol> output) { + stdcxx::shared_ptr<TProtocol> input, + stdcxx::shared_ptr<TProtocol> output) { (void)serverContext; (void)input; (void)output; @@ -80,7 +80,7 @@ public: /** * Called when a client is about to call the processor. */ - virtual void processContext(void* serverContext, boost::shared_ptr<TTransport> transport) { + virtual void processContext(void* serverContext, stdcxx::shared_ptr<TTransport> transport) { (void)serverContext; (void)transport; } @@ -107,62 +107,62 @@ public: // Allows running the server as a Runnable thread virtual void run() { serve(); } - boost::shared_ptr<TProcessorFactory> getProcessorFactory() { return processorFactory_; } + stdcxx::shared_ptr<TProcessorFactory> getProcessorFactory() { return processorFactory_; } - boost::shared_ptr<TServerTransport> getServerTransport() { return serverTransport_; } + stdcxx::shared_ptr<TServerTransport> getServerTransport() { return serverTransport_; } - boost::shared_ptr<TTransportFactory> getInputTransportFactory() { return inputTransportFactory_; } + stdcxx::shared_ptr<TTransportFactory> getInputTransportFactory() { return inputTransportFactory_; } - boost::shared_ptr<TTransportFactory> getOutputTransportFactory() { + stdcxx::shared_ptr<TTransportFactory> getOutputTransportFactory() { return outputTransportFactory_; } - boost::shared_ptr<TProtocolFactory> getInputProtocolFactory() { return inputProtocolFactory_; } + stdcxx::shared_ptr<TProtocolFactory> getInputProtocolFactory() { return inputProtocolFactory_; } - boost::shared_ptr<TProtocolFactory> getOutputProtocolFactory() { return outputProtocolFactory_; } + stdcxx::shared_ptr<TProtocolFactory> getOutputProtocolFactory() { return outputProtocolFactory_; } - boost::shared_ptr<TServerEventHandler> getEventHandler() { return eventHandler_; } + stdcxx::shared_ptr<TServerEventHandler> getEventHandler() { return eventHandler_; } protected: - TServer(const boost::shared_ptr<TProcessorFactory>& processorFactory) + TServer(const stdcxx::shared_ptr<TProcessorFactory>& processorFactory) : processorFactory_(processorFactory) { - setInputTransportFactory(boost::shared_ptr<TTransportFactory>(new TTransportFactory())); - setOutputTransportFactory(boost::shared_ptr<TTransportFactory>(new TTransportFactory())); - setInputProtocolFactory(boost::shared_ptr<TProtocolFactory>(new TBinaryProtocolFactory())); - setOutputProtocolFactory(boost::shared_ptr<TProtocolFactory>(new TBinaryProtocolFactory())); + setInputTransportFactory(stdcxx::shared_ptr<TTransportFactory>(new TTransportFactory())); + setOutputTransportFactory(stdcxx::shared_ptr<TTransportFactory>(new TTransportFactory())); + setInputProtocolFactory(stdcxx::shared_ptr<TProtocolFactory>(new TBinaryProtocolFactory())); + setOutputProtocolFactory(stdcxx::shared_ptr<TProtocolFactory>(new TBinaryProtocolFactory())); } - TServer(const boost::shared_ptr<TProcessor>& processor) + TServer(const stdcxx::shared_ptr<TProcessor>& processor) : processorFactory_(new TSingletonProcessorFactory(processor)) { - setInputTransportFactory(boost::shared_ptr<TTransportFactory>(new TTransportFactory())); - setOutputTransportFactory(boost::shared_ptr<TTransportFactory>(new TTransportFactory())); - setInputProtocolFactory(boost::shared_ptr<TProtocolFactory>(new TBinaryProtocolFactory())); - setOutputProtocolFactory(boost::shared_ptr<TProtocolFactory>(new TBinaryProtocolFactory())); + setInputTransportFactory(stdcxx::shared_ptr<TTransportFactory>(new TTransportFactory())); + setOutputTransportFactory(stdcxx::shared_ptr<TTransportFactory>(new TTransportFactory())); + setInputProtocolFactory(stdcxx::shared_ptr<TProtocolFactory>(new TBinaryProtocolFactory())); + setOutputProtocolFactory(stdcxx::shared_ptr<TProtocolFactory>(new TBinaryProtocolFactory())); } - TServer(const boost::shared_ptr<TProcessorFactory>& processorFactory, - const boost::shared_ptr<TServerTransport>& serverTransport) + TServer(const stdcxx::shared_ptr<TProcessorFactory>& processorFactory, + const stdcxx::shared_ptr<TServerTransport>& serverTransport) : processorFactory_(processorFactory), serverTransport_(serverTransport) { - setInputTransportFactory(boost::shared_ptr<TTransportFactory>(new TTransportFactory())); - setOutputTransportFactory(boost::shared_ptr<TTransportFactory>(new TTransportFactory())); - setInputProtocolFactory(boost::shared_ptr<TProtocolFactory>(new TBinaryProtocolFactory())); - setOutputProtocolFactory(boost::shared_ptr<TProtocolFactory>(new TBinaryProtocolFactory())); + setInputTransportFactory(stdcxx::shared_ptr<TTransportFactory>(new TTransportFactory())); + setOutputTransportFactory(stdcxx::shared_ptr<TTransportFactory>(new TTransportFactory())); + setInputProtocolFactory(stdcxx::shared_ptr<TProtocolFactory>(new TBinaryProtocolFactory())); + setOutputProtocolFactory(stdcxx::shared_ptr<TProtocolFactory>(new TBinaryProtocolFactory())); } - TServer(const boost::shared_ptr<TProcessor>& processor, - const boost::shared_ptr<TServerTransport>& serverTransport) + TServer(const stdcxx::shared_ptr<TProcessor>& processor, + const stdcxx::shared_ptr<TServerTransport>& serverTransport) : processorFactory_(new TSingletonProcessorFactory(processor)), serverTransport_(serverTransport) { - setInputTransportFactory(boost::shared_ptr<TTransportFactory>(new TTransportFactory())); - setOutputTransportFactory(boost::shared_ptr<TTransportFactory>(new TTransportFactory())); - setInputProtocolFactory(boost::shared_ptr<TProtocolFactory>(new TBinaryProtocolFactory())); - setOutputProtocolFactory(boost::shared_ptr<TProtocolFactory>(new TBinaryProtocolFactory())); + setInputTransportFactory(stdcxx::shared_ptr<TTransportFactory>(new TTransportFactory())); + setOutputTransportFactory(stdcxx::shared_ptr<TTransportFactory>(new TTransportFactory())); + setInputProtocolFactory(stdcxx::shared_ptr<TProtocolFactory>(new TBinaryProtocolFactory())); + setOutputProtocolFactory(stdcxx::shared_ptr<TProtocolFactory>(new TBinaryProtocolFactory())); } - TServer(const boost::shared_ptr<TProcessorFactory>& processorFactory, - const boost::shared_ptr<TServerTransport>& serverTransport, - const boost::shared_ptr<TTransportFactory>& transportFactory, - const boost::shared_ptr<TProtocolFactory>& protocolFactory) + TServer(const stdcxx::shared_ptr<TProcessorFactory>& processorFactory, + const stdcxx::shared_ptr<TServerTransport>& serverTransport, + const stdcxx::shared_ptr<TTransportFactory>& transportFactory, + const stdcxx::shared_ptr<TProtocolFactory>& protocolFactory) : processorFactory_(processorFactory), serverTransport_(serverTransport), inputTransportFactory_(transportFactory), @@ -170,10 +170,10 @@ protected: inputProtocolFactory_(protocolFactory), outputProtocolFactory_(protocolFactory) {} - TServer(const boost::shared_ptr<TProcessor>& processor, - const boost::shared_ptr<TServerTransport>& serverTransport, - const boost::shared_ptr<TTransportFactory>& transportFactory, - const boost::shared_ptr<TProtocolFactory>& protocolFactory) + TServer(const stdcxx::shared_ptr<TProcessor>& processor, + const stdcxx::shared_ptr<TServerTransport>& serverTransport, + const stdcxx::shared_ptr<TTransportFactory>& transportFactory, + const stdcxx::shared_ptr<TProtocolFactory>& protocolFactory) : processorFactory_(new TSingletonProcessorFactory(processor)), serverTransport_(serverTransport), inputTransportFactory_(transportFactory), @@ -181,12 +181,12 @@ protected: inputProtocolFactory_(protocolFactory), outputProtocolFactory_(protocolFactory) {} - TServer(const boost::shared_ptr<TProcessorFactory>& processorFactory, - const boost::shared_ptr<TServerTransport>& serverTransport, - const boost::shared_ptr<TTransportFactory>& inputTransportFactory, - const boost::shared_ptr<TTransportFactory>& outputTransportFactory, - const boost::shared_ptr<TProtocolFactory>& inputProtocolFactory, - const boost::shared_ptr<TProtocolFactory>& outputProtocolFactory) + TServer(const stdcxx::shared_ptr<TProcessorFactory>& processorFactory, + const stdcxx::shared_ptr<TServerTransport>& serverTransport, + const stdcxx::shared_ptr<TTransportFactory>& inputTransportFactory, + const stdcxx::shared_ptr<TTransportFactory>& outputTransportFactory, + const stdcxx::shared_ptr<TProtocolFactory>& inputProtocolFactory, + const stdcxx::shared_ptr<TProtocolFactory>& outputProtocolFactory) : processorFactory_(processorFactory), serverTransport_(serverTransport), inputTransportFactory_(inputTransportFactory), @@ -194,12 +194,12 @@ protected: inputProtocolFactory_(inputProtocolFactory), outputProtocolFactory_(outputProtocolFactory) {} - TServer(const boost::shared_ptr<TProcessor>& processor, - const boost::shared_ptr<TServerTransport>& serverTransport, - const boost::shared_ptr<TTransportFactory>& inputTransportFactory, - const boost::shared_ptr<TTransportFactory>& outputTransportFactory, - const boost::shared_ptr<TProtocolFactory>& inputProtocolFactory, - const boost::shared_ptr<TProtocolFactory>& outputProtocolFactory) + TServer(const stdcxx::shared_ptr<TProcessor>& processor, + const stdcxx::shared_ptr<TServerTransport>& serverTransport, + const stdcxx::shared_ptr<TTransportFactory>& inputTransportFactory, + const stdcxx::shared_ptr<TTransportFactory>& outputTransportFactory, + const stdcxx::shared_ptr<TProtocolFactory>& inputProtocolFactory, + const stdcxx::shared_ptr<TProtocolFactory>& outputProtocolFactory) : processorFactory_(new TSingletonProcessorFactory(processor)), serverTransport_(serverTransport), inputTransportFactory_(inputTransportFactory), @@ -214,9 +214,9 @@ protected: * call). This allows the TProcessorFactory to return a different processor * for each connection if it desires. */ - boost::shared_ptr<TProcessor> getProcessor(boost::shared_ptr<TProtocol> inputProtocol, - boost::shared_ptr<TProtocol> outputProtocol, - boost::shared_ptr<TTransport> transport) { + stdcxx::shared_ptr<TProcessor> getProcessor(stdcxx::shared_ptr<TProtocol> inputProtocol, + stdcxx::shared_ptr<TProtocol> outputProtocol, + stdcxx::shared_ptr<TTransport> transport) { TConnectionInfo connInfo; connInfo.input = inputProtocol; connInfo.output = outputProtocol; @@ -225,35 +225,35 @@ protected: } // Class variables - boost::shared_ptr<TProcessorFactory> processorFactory_; - boost::shared_ptr<TServerTransport> serverTransport_; + stdcxx::shared_ptr<TProcessorFactory> processorFactory_; + stdcxx::shared_ptr<TServerTransport> serverTransport_; - boost::shared_ptr<TTransportFactory> inputTransportFactory_; - boost::shared_ptr<TTransportFactory> outputTransportFactory_; + stdcxx::shared_ptr<TTransportFactory> inputTransportFactory_; + stdcxx::shared_ptr<TTransportFactory> outputTransportFactory_; - boost::shared_ptr<TProtocolFactory> inputProtocolFactory_; - boost::shared_ptr<TProtocolFactory> outputProtocolFactory_; + stdcxx::shared_ptr<TProtocolFactory> inputProtocolFactory_; + stdcxx::shared_ptr<TProtocolFactory> outputProtocolFactory_; - boost::shared_ptr<TServerEventHandler> eventHandler_; + stdcxx::shared_ptr<TServerEventHandler> eventHandler_; public: - void setInputTransportFactory(boost::shared_ptr<TTransportFactory> inputTransportFactory) { + void setInputTransportFactory(stdcxx::shared_ptr<TTransportFactory> inputTransportFactory) { inputTransportFactory_ = inputTransportFactory; } - void setOutputTransportFactory(boost::shared_ptr<TTransportFactory> outputTransportFactory) { + void setOutputTransportFactory(stdcxx::shared_ptr<TTransportFactory> outputTransportFactory) { outputTransportFactory_ = outputTransportFactory; } - void setInputProtocolFactory(boost::shared_ptr<TProtocolFactory> inputProtocolFactory) { + void setInputProtocolFactory(stdcxx::shared_ptr<TProtocolFactory> inputProtocolFactory) { inputProtocolFactory_ = inputProtocolFactory; } - void setOutputProtocolFactory(boost::shared_ptr<TProtocolFactory> outputProtocolFactory) { + void setOutputProtocolFactory(stdcxx::shared_ptr<TProtocolFactory> outputProtocolFactory) { outputProtocolFactory_ = outputProtocolFactory; } - void setServerEventHandler(boost::shared_ptr<TServerEventHandler> eventHandler) { + void setServerEventHandler(stdcxx::shared_ptr<TServerEventHandler> eventHandler) { eventHandler_ = eventHandler; } }; diff --git a/lib/cpp/src/thrift/server/TServerFramework.cpp b/lib/cpp/src/thrift/server/TServerFramework.cpp index b62cf4075..ae38336d4 100644 --- a/lib/cpp/src/thrift/server/TServerFramework.cpp +++ b/lib/cpp/src/thrift/server/TServerFramework.cpp @@ -18,7 +18,6 @@ */ #include <algorithm> -#include <boost/bind.hpp> #include <stdexcept> #include <stdint.h> #include <thrift/server/TServerFramework.h> @@ -28,14 +27,14 @@ namespace thrift { namespace server { using apache::thrift::concurrency::Synchronized; +using apache::thrift::protocol::TProtocol; +using apache::thrift::protocol::TProtocolFactory; +using apache::thrift::stdcxx::bind; +using apache::thrift::stdcxx::shared_ptr; using apache::thrift::transport::TServerTransport; using apache::thrift::transport::TTransport; using apache::thrift::transport::TTransportException; using apache::thrift::transport::TTransportFactory; -using apache::thrift::protocol::TProtocol; -using apache::thrift::protocol::TProtocolFactory; -using boost::bind; -using boost::shared_ptr; using std::string; TServerFramework::TServerFramework(const shared_ptr<TProcessorFactory>& processorFactory, @@ -162,7 +161,7 @@ void TServerFramework::serve() { outputProtocol, eventHandler_, client), - bind(&TServerFramework::disposeConnectedClient, this, _1))); + bind(&TServerFramework::disposeConnectedClient, this, stdcxx::placeholders::_1))); } catch (TTransportException& ttx) { releaseOneDescriptor("inputTransport", inputTransport); @@ -221,7 +220,7 @@ void TServerFramework::stop() { serverTransport_->interrupt(); } -void TServerFramework::newlyConnectedClient(const boost::shared_ptr<TConnectedClient>& pClient) { +void TServerFramework::newlyConnectedClient(const shared_ptr<TConnectedClient>& pClient) { { Synchronized sync(mon_); ++clients_; diff --git a/lib/cpp/src/thrift/server/TServerFramework.h b/lib/cpp/src/thrift/server/TServerFramework.h index 53d9bfd3e..706fd490a 100644 --- a/lib/cpp/src/thrift/server/TServerFramework.h +++ b/lib/cpp/src/thrift/server/TServerFramework.h @@ -20,7 +20,7 @@ #ifndef _THRIFT_SERVER_TSERVERFRAMEWORK_H_ #define _THRIFT_SERVER_TSERVERFRAMEWORK_H_ 1 -#include <boost/shared_ptr.hpp> +#include <thrift/stdcxx.h> #include <stdint.h> #include <thrift/TProcessor.h> #include <thrift/concurrency/Monitor.h> @@ -48,32 +48,32 @@ namespace server { class TServerFramework : public TServer { public: TServerFramework( - const boost::shared_ptr<apache::thrift::TProcessorFactory>& processorFactory, - const boost::shared_ptr<apache::thrift::transport::TServerTransport>& serverTransport, - const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& transportFactory, - const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& protocolFactory); + const stdcxx::shared_ptr<apache::thrift::TProcessorFactory>& processorFactory, + const stdcxx::shared_ptr<apache::thrift::transport::TServerTransport>& serverTransport, + const stdcxx::shared_ptr<apache::thrift::transport::TTransportFactory>& transportFactory, + const stdcxx::shared_ptr<apache::thrift::protocol::TProtocolFactory>& protocolFactory); TServerFramework( - const boost::shared_ptr<apache::thrift::TProcessor>& processor, - const boost::shared_ptr<apache::thrift::transport::TServerTransport>& serverTransport, - const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& transportFactory, - const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& protocolFactory); + const stdcxx::shared_ptr<apache::thrift::TProcessor>& processor, + const stdcxx::shared_ptr<apache::thrift::transport::TServerTransport>& serverTransport, + const stdcxx::shared_ptr<apache::thrift::transport::TTransportFactory>& transportFactory, + const stdcxx::shared_ptr<apache::thrift::protocol::TProtocolFactory>& protocolFactory); TServerFramework( - const boost::shared_ptr<apache::thrift::TProcessorFactory>& processorFactory, - const boost::shared_ptr<apache::thrift::transport::TServerTransport>& serverTransport, - const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& inputTransportFactory, - const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& outputTransportFactory, - const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& inputProtocolFactory, - const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& outputProtocolFactory); + const stdcxx::shared_ptr<apache::thrift::TProcessorFactory>& processorFactory, + const stdcxx::shared_ptr<apache::thrift::transport::TServerTransport>& serverTransport, + const stdcxx::shared_ptr<apache::thrift::transport::TTransportFactory>& inputTransportFactory, + const stdcxx::shared_ptr<apache::thrift::transport::TTransportFactory>& outputTransportFactory, + const stdcxx::shared_ptr<apache::thrift::protocol::TProtocolFactory>& inputProtocolFactory, + const stdcxx::shared_ptr<apache::thrift::protocol::TProtocolFactory>& outputProtocolFactory); TServerFramework( - const boost::shared_ptr<apache::thrift::TProcessor>& processor, - const boost::shared_ptr<apache::thrift::transport::TServerTransport>& serverTransport, - const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& inputTransportFactory, - const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& outputTransportFactory, - const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& inputProtocolFactory, - const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& outputProtocolFactory); + const stdcxx::shared_ptr<apache::thrift::TProcessor>& processor, + const stdcxx::shared_ptr<apache::thrift::transport::TServerTransport>& serverTransport, + const stdcxx::shared_ptr<apache::thrift::transport::TTransportFactory>& inputTransportFactory, + const stdcxx::shared_ptr<apache::thrift::transport::TTransportFactory>& outputTransportFactory, + const stdcxx::shared_ptr<apache::thrift::protocol::TProtocolFactory>& inputProtocolFactory, + const stdcxx::shared_ptr<apache::thrift::protocol::TProtocolFactory>& outputProtocolFactory); virtual ~TServerFramework(); @@ -130,7 +130,7 @@ protected: * * \param[in] pClient the newly connected client */ - virtual void onClientConnected(const boost::shared_ptr<TConnectedClient>& pClient) = 0; + virtual void onClientConnected(const stdcxx::shared_ptr<TConnectedClient>& pClient) = 0; /** * A client has disconnected. @@ -149,7 +149,7 @@ private: * client rate limiting after onClientConnected returns by blocking the * serve() thread if the limit has been reached. */ - void newlyConnectedClient(const boost::shared_ptr<TConnectedClient>& pClient); + void newlyConnectedClient(const stdcxx::shared_ptr<TConnectedClient>& pClient); /** * Smart pointer client deletion. diff --git a/lib/cpp/src/thrift/server/TSimpleServer.cpp b/lib/cpp/src/thrift/server/TSimpleServer.cpp index 2f69ff421..a0afbbe73 100644 --- a/lib/cpp/src/thrift/server/TSimpleServer.cpp +++ b/lib/cpp/src/thrift/server/TSimpleServer.cpp @@ -29,7 +29,7 @@ using apache::thrift::transport::TServerTransport; using apache::thrift::transport::TTransport; using apache::thrift::transport::TTransportException; using apache::thrift::transport::TTransportFactory; -using boost::shared_ptr; +using stdcxx::shared_ptr; using std::string; TSimpleServer::TSimpleServer(const shared_ptr<TProcessorFactory>& processorFactory, diff --git a/lib/cpp/src/thrift/server/TSimpleServer.h b/lib/cpp/src/thrift/server/TSimpleServer.h index 391fbec8c..ac4ed34ea 100644 --- a/lib/cpp/src/thrift/server/TSimpleServer.h +++ b/lib/cpp/src/thrift/server/TSimpleServer.h @@ -34,37 +34,37 @@ namespace server { class TSimpleServer : public TServerFramework { public: TSimpleServer( - const boost::shared_ptr<apache::thrift::TProcessorFactory>& processorFactory, - const boost::shared_ptr<apache::thrift::transport::TServerTransport>& serverTransport, - const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& transportFactory, - const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& protocolFactory); + const stdcxx::shared_ptr<apache::thrift::TProcessorFactory>& processorFactory, + const stdcxx::shared_ptr<apache::thrift::transport::TServerTransport>& serverTransport, + const stdcxx::shared_ptr<apache::thrift::transport::TTransportFactory>& transportFactory, + const stdcxx::shared_ptr<apache::thrift::protocol::TProtocolFactory>& protocolFactory); TSimpleServer( - const boost::shared_ptr<apache::thrift::TProcessor>& processor, - const boost::shared_ptr<apache::thrift::transport::TServerTransport>& serverTransport, - const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& transportFactory, - const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& protocolFactory); + const stdcxx::shared_ptr<apache::thrift::TProcessor>& processor, + const stdcxx::shared_ptr<apache::thrift::transport::TServerTransport>& serverTransport, + const stdcxx::shared_ptr<apache::thrift::transport::TTransportFactory>& transportFactory, + const stdcxx::shared_ptr<apache::thrift::protocol::TProtocolFactory>& protocolFactory); TSimpleServer( - const boost::shared_ptr<apache::thrift::TProcessorFactory>& processorFactory, - const boost::shared_ptr<apache::thrift::transport::TServerTransport>& serverTransport, - const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& inputTransportFactory, - const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& outputTransportFactory, - const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& inputProtocolFactory, - const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& outputProtocolFactory); + const stdcxx::shared_ptr<apache::thrift::TProcessorFactory>& processorFactory, + const stdcxx::shared_ptr<apache::thrift::transport::TServerTransport>& serverTransport, + const stdcxx::shared_ptr<apache::thrift::transport::TTransportFactory>& inputTransportFactory, + const stdcxx::shared_ptr<apache::thrift::transport::TTransportFactory>& outputTransportFactory, + const stdcxx::shared_ptr<apache::thrift::protocol::TProtocolFactory>& inputProtocolFactory, + const stdcxx::shared_ptr<apache::thrift::protocol::TProtocolFactory>& outputProtocolFactory); TSimpleServer( - const boost::shared_ptr<apache::thrift::TProcessor>& processor, - const boost::shared_ptr<apache::thrift::transport::TServerTransport>& serverTransport, - const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& inputTransportFactory, - const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& outputTransportFactory, - const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& inputProtocolFactory, - const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& outputProtocolFactory); + const stdcxx::shared_ptr<apache::thrift::TProcessor>& processor, + const stdcxx::shared_ptr<apache::thrift::transport::TServerTransport>& serverTransport, + const stdcxx::shared_ptr<apache::thrift::transport::TTransportFactory>& inputTransportFactory, + const stdcxx::shared_ptr<apache::thrift::transport::TTransportFactory>& outputTransportFactory, + const stdcxx::shared_ptr<apache::thrift::protocol::TProtocolFactory>& inputProtocolFactory, + const stdcxx::shared_ptr<apache::thrift::protocol::TProtocolFactory>& outputProtocolFactory); virtual ~TSimpleServer(); protected: - virtual void onClientConnected(const boost::shared_ptr<TConnectedClient>& pClient) /* override */; + virtual void onClientConnected(const stdcxx::shared_ptr<TConnectedClient>& pClient) /* override */; virtual void onClientDisconnected(TConnectedClient* pClient) /* override */; private: diff --git a/lib/cpp/src/thrift/server/TThreadPoolServer.cpp b/lib/cpp/src/thrift/server/TThreadPoolServer.cpp index 63af85cb9..f07ff849d 100644 --- a/lib/cpp/src/thrift/server/TThreadPoolServer.cpp +++ b/lib/cpp/src/thrift/server/TThreadPoolServer.cpp @@ -30,7 +30,7 @@ using apache::thrift::transport::TServerTransport; using apache::thrift::transport::TTransport; using apache::thrift::transport::TTransportException; using apache::thrift::transport::TTransportFactory; -using boost::shared_ptr; +using stdcxx::shared_ptr; using std::string; TThreadPoolServer::TThreadPoolServer(const shared_ptr<TProcessorFactory>& processorFactory, @@ -115,7 +115,7 @@ void TThreadPoolServer::setTaskExpiration(int64_t value) { taskExpiration_ = value; } -boost::shared_ptr<apache::thrift::concurrency::ThreadManager> +stdcxx::shared_ptr<apache::thrift::concurrency::ThreadManager> TThreadPoolServer::getThreadManager() const { return threadManager_; } diff --git a/lib/cpp/src/thrift/server/TThreadPoolServer.h b/lib/cpp/src/thrift/server/TThreadPoolServer.h index c750b8cf7..94088d5d0 100644 --- a/lib/cpp/src/thrift/server/TThreadPoolServer.h +++ b/lib/cpp/src/thrift/server/TThreadPoolServer.h @@ -34,39 +34,39 @@ namespace server { class TThreadPoolServer : public TServerFramework { public: TThreadPoolServer( - const boost::shared_ptr<apache::thrift::TProcessorFactory>& processorFactory, - const boost::shared_ptr<apache::thrift::transport::TServerTransport>& serverTransport, - const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& transportFactory, - const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& protocolFactory, - const boost::shared_ptr<apache::thrift::concurrency::ThreadManager>& threadManager + const stdcxx::shared_ptr<apache::thrift::TProcessorFactory>& processorFactory, + const stdcxx::shared_ptr<apache::thrift::transport::TServerTransport>& serverTransport, + const stdcxx::shared_ptr<apache::thrift::transport::TTransportFactory>& transportFactory, + const stdcxx::shared_ptr<apache::thrift::protocol::TProtocolFactory>& protocolFactory, + const stdcxx::shared_ptr<apache::thrift::concurrency::ThreadManager>& threadManager = apache::thrift::concurrency::ThreadManager::newSimpleThreadManager()); TThreadPoolServer( - const boost::shared_ptr<apache::thrift::TProcessor>& processor, - const boost::shared_ptr<apache::thrift::transport::TServerTransport>& serverTransport, - const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& transportFactory, - const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& protocolFactory, - const boost::shared_ptr<apache::thrift::concurrency::ThreadManager>& threadManager + const stdcxx::shared_ptr<apache::thrift::TProcessor>& processor, + const stdcxx::shared_ptr<apache::thrift::transport::TServerTransport>& serverTransport, + const stdcxx::shared_ptr<apache::thrift::transport::TTransportFactory>& transportFactory, + const stdcxx::shared_ptr<apache::thrift::protocol::TProtocolFactory>& protocolFactory, + const stdcxx::shared_ptr<apache::thrift::concurrency::ThreadManager>& threadManager = apache::thrift::concurrency::ThreadManager::newSimpleThreadManager()); TThreadPoolServer( - const boost::shared_ptr<apache::thrift::TProcessorFactory>& processorFactory, - const boost::shared_ptr<apache::thrift::transport::TServerTransport>& serverTransport, - const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& inputTransportFactory, - const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& outputTransportFactory, - const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& inputProtocolFactory, - const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& outputProtocolFactory, - const boost::shared_ptr<apache::thrift::concurrency::ThreadManager>& threadManager + const stdcxx::shared_ptr<apache::thrift::TProcessorFactory>& processorFactory, + const stdcxx::shared_ptr<apache::thrift::transport::TServerTransport>& serverTransport, + const stdcxx::shared_ptr<apache::thrift::transport::TTransportFactory>& inputTransportFactory, + const stdcxx::shared_ptr<apache::thrift::transport::TTransportFactory>& outputTransportFactory, + const stdcxx::shared_ptr<apache::thrift::protocol::TProtocolFactory>& inputProtocolFactory, + const stdcxx::shared_ptr<apache::thrift::protocol::TProtocolFactory>& outputProtocolFactory, + const stdcxx::shared_ptr<apache::thrift::concurrency::ThreadManager>& threadManager = apache::thrift::concurrency::ThreadManager::newSimpleThreadManager()); TThreadPoolServer( - const boost::shared_ptr<apache::thrift::TProcessor>& processor, - const boost::shared_ptr<apache::thrift::transport::TServerTransport>& serverTransport, - const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& inputTransportFactory, - const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& outputTransportFactory, - const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& inputProtocolFactory, - const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& outputProtocolFactory, - const boost::shared_ptr<apache::thrift::concurrency::ThreadManager>& threadManager + const stdcxx::shared_ptr<apache::thrift::TProcessor>& processor, + const stdcxx::shared_ptr<apache::thrift::transport::TServerTransport>& serverTransport, + const stdcxx::shared_ptr<apache::thrift::transport::TTransportFactory>& inputTransportFactory, + const stdcxx::shared_ptr<apache::thrift::transport::TTransportFactory>& outputTransportFactory, + const stdcxx::shared_ptr<apache::thrift::protocol::TProtocolFactory>& inputProtocolFactory, + const stdcxx::shared_ptr<apache::thrift::protocol::TProtocolFactory>& outputProtocolFactory, + const stdcxx::shared_ptr<apache::thrift::concurrency::ThreadManager>& threadManager = apache::thrift::concurrency::ThreadManager::newSimpleThreadManager()); virtual ~TThreadPoolServer(); @@ -83,13 +83,13 @@ public: virtual int64_t getTaskExpiration() const; virtual void setTaskExpiration(int64_t value); - virtual boost::shared_ptr<apache::thrift::concurrency::ThreadManager> getThreadManager() const; + virtual stdcxx::shared_ptr<apache::thrift::concurrency::ThreadManager> getThreadManager() const; protected: - virtual void onClientConnected(const boost::shared_ptr<TConnectedClient>& pClient) /* override */; + virtual void onClientConnected(const stdcxx::shared_ptr<TConnectedClient>& pClient) /* override */; virtual void onClientDisconnected(TConnectedClient* pClient) /* override */; - boost::shared_ptr<apache::thrift::concurrency::ThreadManager> threadManager_; + stdcxx::shared_ptr<apache::thrift::concurrency::ThreadManager> threadManager_; boost::atomic<int64_t> timeout_; boost::atomic<int64_t> taskExpiration_; }; diff --git a/lib/cpp/src/thrift/server/TThreadedServer.cpp b/lib/cpp/src/thrift/server/TThreadedServer.cpp index c413be166..8a07db924 100644 --- a/lib/cpp/src/thrift/server/TThreadedServer.cpp +++ b/lib/cpp/src/thrift/server/TThreadedServer.cpp @@ -17,11 +17,8 @@ * under the License. */ -#include <boost/bind.hpp> -#include <boost/function.hpp> -#include <boost/make_shared.hpp> -#include <boost/shared_ptr.hpp> #include <string> +#include <thrift/stdcxx.h> #include <thrift/concurrency/PlatformThreadFactory.h> #include <thrift/server/TThreadedServer.h> @@ -35,11 +32,12 @@ using apache::thrift::concurrency::Thread; using apache::thrift::concurrency::ThreadFactory; using apache::thrift::protocol::TProtocol; using apache::thrift::protocol::TProtocolFactory; +using apache::thrift::stdcxx::make_shared; +using apache::thrift::stdcxx::shared_ptr; using apache::thrift::transport::TServerTransport; using apache::thrift::transport::TTransport; using apache::thrift::transport::TTransportException; using apache::thrift::transport::TTransportFactory; -using boost::shared_ptr; TThreadedServer::TThreadedServer(const shared_ptr<TProcessorFactory>& processorFactory, const shared_ptr<TServerTransport>& serverTransport, @@ -117,8 +115,8 @@ void TThreadedServer::drainDeadClients() { void TThreadedServer::onClientConnected(const shared_ptr<TConnectedClient>& pClient) { Synchronized sync(clientMonitor_); - boost::shared_ptr<TConnectedClientRunner> pRunnable = boost::make_shared<TConnectedClientRunner>(pClient); - boost::shared_ptr<Thread> pThread = threadFactory_->newThread(pRunnable); + shared_ptr<TConnectedClientRunner> pRunnable = make_shared<TConnectedClientRunner>(pClient); + shared_ptr<Thread> pThread = threadFactory_->newThread(pRunnable); pRunnable->thread(pThread); activeClientMap_.insert(ClientMap::value_type(pClient.get(), pThread)); pThread->start(); @@ -136,7 +134,7 @@ void TThreadedServer::onClientDisconnected(TConnectedClient* pClient) { } } -TThreadedServer::TConnectedClientRunner::TConnectedClientRunner(const boost::shared_ptr<TConnectedClient>& pClient) +TThreadedServer::TConnectedClientRunner::TConnectedClientRunner(const shared_ptr<TConnectedClient>& pClient) : pClient_(pClient) { } diff --git a/lib/cpp/src/thrift/server/TThreadedServer.h b/lib/cpp/src/thrift/server/TThreadedServer.h index 56da9012e..1e0a824d3 100644 --- a/lib/cpp/src/thrift/server/TThreadedServer.h +++ b/lib/cpp/src/thrift/server/TThreadedServer.h @@ -38,43 +38,43 @@ namespace server { class TThreadedServer : public TServerFramework { public: TThreadedServer( - const boost::shared_ptr<apache::thrift::TProcessorFactory>& processorFactory, - const boost::shared_ptr<apache::thrift::transport::TServerTransport>& serverTransport, - const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& transportFactory, - const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& protocolFactory, - const boost::shared_ptr<apache::thrift::concurrency::ThreadFactory>& threadFactory - = boost::shared_ptr<apache::thrift::concurrency::ThreadFactory>( + const stdcxx::shared_ptr<apache::thrift::TProcessorFactory>& processorFactory, + const stdcxx::shared_ptr<apache::thrift::transport::TServerTransport>& serverTransport, + const stdcxx::shared_ptr<apache::thrift::transport::TTransportFactory>& transportFactory, + const stdcxx::shared_ptr<apache::thrift::protocol::TProtocolFactory>& protocolFactory, + const stdcxx::shared_ptr<apache::thrift::concurrency::ThreadFactory>& threadFactory + = stdcxx::shared_ptr<apache::thrift::concurrency::ThreadFactory>( new apache::thrift::concurrency::PlatformThreadFactory(false))); TThreadedServer( - const boost::shared_ptr<apache::thrift::TProcessor>& processor, - const boost::shared_ptr<apache::thrift::transport::TServerTransport>& serverTransport, - const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& transportFactory, - const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& protocolFactory, - const boost::shared_ptr<apache::thrift::concurrency::ThreadFactory>& threadFactory - = boost::shared_ptr<apache::thrift::concurrency::ThreadFactory>( + const stdcxx::shared_ptr<apache::thrift::TProcessor>& processor, + const stdcxx::shared_ptr<apache::thrift::transport::TServerTransport>& serverTransport, + const stdcxx::shared_ptr<apache::thrift::transport::TTransportFactory>& transportFactory, + const stdcxx::shared_ptr<apache::thrift::protocol::TProtocolFactory>& protocolFactory, + const stdcxx::shared_ptr<apache::thrift::concurrency::ThreadFactory>& threadFactory + = stdcxx::shared_ptr<apache::thrift::concurrency::ThreadFactory>( new apache::thrift::concurrency::PlatformThreadFactory(false))); TThreadedServer( - const boost::shared_ptr<apache::thrift::TProcessorFactory>& processorFactory, - const boost::shared_ptr<apache::thrift::transport::TServerTransport>& serverTransport, - const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& inputTransportFactory, - const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& outputTransportFactory, - const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& inputProtocolFactory, - const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& outputProtocolFactory, - const boost::shared_ptr<apache::thrift::concurrency::ThreadFactory>& threadFactory - = boost::shared_ptr<apache::thrift::concurrency::ThreadFactory>( + const stdcxx::shared_ptr<apache::thrift::TProcessorFactory>& processorFactory, + const stdcxx::shared_ptr<apache::thrift::transport::TServerTransport>& serverTransport, + const stdcxx::shared_ptr<apache::thrift::transport::TTransportFactory>& inputTransportFactory, + const stdcxx::shared_ptr<apache::thrift::transport::TTransportFactory>& outputTransportFactory, + const stdcxx::shared_ptr<apache::thrift::protocol::TProtocolFactory>& inputProtocolFactory, + const stdcxx::shared_ptr<apache::thrift::protocol::TProtocolFactory>& outputProtocolFactory, + const stdcxx::shared_ptr<apache::thrift::concurrency::ThreadFactory>& threadFactory + = stdcxx::shared_ptr<apache::thrift::concurrency::ThreadFactory>( new apache::thrift::concurrency::PlatformThreadFactory(false))); TThreadedServer( - const boost::shared_ptr<apache::thrift::TProcessor>& processor, - const boost::shared_ptr<apache::thrift::transport::TServerTransport>& serverTransport, - const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& inputTransportFactory, - const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& outputTransportFactory, - const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& inputProtocolFactory, - const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& outputProtocolFactory, - const boost::shared_ptr<apache::thrift::concurrency::ThreadFactory>& threadFactory - = boost::shared_ptr<apache::thrift::concurrency::ThreadFactory>( + const stdcxx::shared_ptr<apache::thrift::TProcessor>& processor, + const stdcxx::shared_ptr<apache::thrift::transport::TServerTransport>& serverTransport, + const stdcxx::shared_ptr<apache::thrift::transport::TTransportFactory>& inputTransportFactory, + const stdcxx::shared_ptr<apache::thrift::transport::TTransportFactory>& outputTransportFactory, + const stdcxx::shared_ptr<apache::thrift::protocol::TProtocolFactory>& inputProtocolFactory, + const stdcxx::shared_ptr<apache::thrift::protocol::TProtocolFactory>& outputProtocolFactory, + const stdcxx::shared_ptr<apache::thrift::concurrency::ThreadFactory>& threadFactory + = stdcxx::shared_ptr<apache::thrift::concurrency::ThreadFactory>( new apache::thrift::concurrency::PlatformThreadFactory(false))); virtual ~TThreadedServer(); @@ -95,14 +95,14 @@ protected: /** * Implementation of TServerFramework::onClientConnected */ - virtual void onClientConnected(const boost::shared_ptr<TConnectedClient>& pClient) /* override */; + virtual void onClientConnected(const stdcxx::shared_ptr<TConnectedClient>& pClient) /* override */; /** * Implementation of TServerFramework::onClientDisconnected */ virtual void onClientDisconnected(TConnectedClient *pClient) /* override */; - boost::shared_ptr<apache::thrift::concurrency::ThreadFactory> threadFactory_; + stdcxx::shared_ptr<apache::thrift::concurrency::ThreadFactory> threadFactory_; /** * A helper wrapper used to wrap the client in something we can use to maintain @@ -114,16 +114,16 @@ protected: class TConnectedClientRunner : public apache::thrift::concurrency::Runnable { public: - TConnectedClientRunner(const boost::shared_ptr<TConnectedClient>& pClient); + TConnectedClientRunner(const stdcxx::shared_ptr<TConnectedClient>& pClient); virtual ~TConnectedClientRunner(); void run() /* override */; private: - boost::shared_ptr<TConnectedClient> pClient_; + stdcxx::shared_ptr<TConnectedClient> pClient_; }; apache::thrift::concurrency::Monitor clientMonitor_; - typedef std::map<TConnectedClient *, boost::shared_ptr<apache::thrift::concurrency::Thread> > ClientMap; + typedef std::map<TConnectedClient *, stdcxx::shared_ptr<apache::thrift::concurrency::Thread> > ClientMap; /** * A map of active clients diff --git a/lib/cpp/src/thrift/stdcxx.h b/lib/cpp/src/thrift/stdcxx.h new file mode 100644 index 000000000..5113940a5 --- /dev/null +++ b/lib/cpp/src/thrift/stdcxx.h @@ -0,0 +1,124 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#ifndef _THRIFT_STDCXX_H_ +#define _THRIFT_STDCXX_H_ 1 + +#include <boost/config.hpp> + +/////////////////////////////////////////////////////////////////// +// +// functional (function, bind) +// +/////////////////////////////////////////////////////////////////// + +#if defined(BOOST_NO_CXX11_HDR_FUNCTIONAL) || (defined(_MSC_VER) && _MSC_VER < 1800) || defined(FORCE_BOOST_FUNCTIONAL) +#include <boost/tr1/functional.hpp> +#define _THRIFT_FUNCTIONAL_TR1_ 1 +#endif + +#if _THRIFT_FUNCTIONAL_TR1_ + + namespace apache { namespace thrift { namespace stdcxx { + + using ::std::tr1::bind; + using ::std::tr1::function; + + namespace placeholders { + using ::std::tr1::placeholders::_1; + using ::std::tr1::placeholders::_2; + using ::std::tr1::placeholders::_3; + using ::std::tr1::placeholders::_4; + using ::std::tr1::placeholders::_5; + using ::std::tr1::placeholders::_6; + using ::std::tr1::placeholders::_7; + using ::std::tr1::placeholders::_8; + using ::std::tr1::placeholders::_9; + } // apache::thrift::stdcxx::placeholders + }}} // apache::thrift::stdcxx + +#else + + #include <functional> + + namespace apache { namespace thrift { namespace stdcxx { + using ::std::bind; + using ::std::function; + + namespace placeholders { + using ::std::placeholders::_1; + using ::std::placeholders::_2; + using ::std::placeholders::_3; + using ::std::placeholders::_4; + using ::std::placeholders::_5; + using ::std::placeholders::_6; + using ::std::placeholders::_7; + using ::std::placeholders::_8; + using ::std::placeholders::_9; + } // apache::thrift::stdcxx::placeholders + }}} // apache::thrift::stdcxx + +#endif + +/////////////////////////////////////////////////////////////////// +// +// Smart Pointers +// +/////////////////////////////////////////////////////////////////// + +// We can use std for memory functions only if the compiler supports template aliasing +// The macro BOOST_NO_CXX11_SMART_PTR is defined as 1 under Visual Studio 2010 and 2012 +// which do not support the feature, so we must continue to use C++98 and boost on them. +// We cannot use __cplusplus to detect this either, since Microsoft advertises an older one. + +#if defined(BOOST_NO_CXX11_SMART_PTR) || (defined(_MSC_VER) && _MSC_VER < 1800) || defined(FORCE_BOOST_SMART_PTR) +#include <boost/smart_ptr.hpp> +#else +#include <memory> +#endif + +namespace apache { namespace thrift { namespace stdcxx { + +#if defined(BOOST_NO_CXX11_SMART_PTR) || (defined(_MSC_VER) && _MSC_VER < 1800) || defined(FORCE_BOOST_SMART_PTR) + + using ::boost::const_pointer_cast; + using ::boost::dynamic_pointer_cast; + using ::boost::enable_shared_from_this; + using ::boost::make_shared; + using ::boost::scoped_ptr; + using ::boost::shared_ptr; + using ::boost::static_pointer_cast; + using ::boost::weak_ptr; + +#else + + using ::std::const_pointer_cast; + using ::std::dynamic_pointer_cast; + using ::std::enable_shared_from_this; + using ::std::make_shared; + template <typename T> using scoped_ptr = std::unique_ptr<T>; // compiler must support template aliasing + using ::std::shared_ptr; + using ::std::static_pointer_cast; + using ::std::weak_ptr; + +#endif + +}}} // apache::thrift::stdcxx + +#endif // #ifndef _THRIFT_STDCXX_H_ diff --git a/lib/cpp/src/thrift/transport/TBufferTransports.h b/lib/cpp/src/thrift/transport/TBufferTransports.h index e690d0c6e..37f459670 100644 --- a/lib/cpp/src/thrift/transport/TBufferTransports.h +++ b/lib/cpp/src/thrift/transport/TBufferTransports.h @@ -186,7 +186,7 @@ public: static const int DEFAULT_BUFFER_SIZE = 512; /// Use default buffer sizes. - TBufferedTransport(boost::shared_ptr<TTransport> transport) + TBufferedTransport(stdcxx::shared_ptr<TTransport> transport) : transport_(transport), rBufSize_(DEFAULT_BUFFER_SIZE), wBufSize_(DEFAULT_BUFFER_SIZE), @@ -196,7 +196,7 @@ public: } /// Use specified buffer sizes. - TBufferedTransport(boost::shared_ptr<TTransport> transport, uint32_t sz) + TBufferedTransport(stdcxx::shared_ptr<TTransport> transport, uint32_t sz) : transport_(transport), rBufSize_(sz), wBufSize_(sz), @@ -206,7 +206,7 @@ public: } /// Use specified read and write buffer sizes. - TBufferedTransport(boost::shared_ptr<TTransport> transport, uint32_t rsz, uint32_t wsz) + TBufferedTransport(stdcxx::shared_ptr<TTransport> transport, uint32_t rsz, uint32_t wsz) : transport_(transport), rBufSize_(rsz), wBufSize_(wsz), @@ -255,7 +255,7 @@ public: */ virtual const uint8_t* borrowSlow(uint8_t* buf, uint32_t* len); - boost::shared_ptr<TTransport> getUnderlyingTransport() { return transport_; } + stdcxx::shared_ptr<TTransport> getUnderlyingTransport() { return transport_; } /* * TVirtualTransport provides a default implementation of readAll(). @@ -270,7 +270,7 @@ protected: // Write size never changes. } - boost::shared_ptr<TTransport> transport_; + stdcxx::shared_ptr<TTransport> transport_; uint32_t rBufSize_; uint32_t wBufSize_; @@ -291,8 +291,8 @@ public: /** * Wraps the transport into a buffered one. */ - virtual boost::shared_ptr<TTransport> getTransport(boost::shared_ptr<TTransport> trans) { - return boost::shared_ptr<TTransport>(new TBufferedTransport(trans)); + virtual stdcxx::shared_ptr<TTransport> getTransport(stdcxx::shared_ptr<TTransport> trans) { + return stdcxx::shared_ptr<TTransport>(new TBufferedTransport(trans)); } }; @@ -319,7 +319,7 @@ public: initPointers(); } - TFramedTransport(boost::shared_ptr<TTransport> transport) + TFramedTransport(stdcxx::shared_ptr<TTransport> transport) : transport_(transport), rBufSize_(0), wBufSize_(DEFAULT_BUFFER_SIZE), @@ -330,7 +330,7 @@ public: initPointers(); } - TFramedTransport(boost::shared_ptr<TTransport> transport, + TFramedTransport(stdcxx::shared_ptr<TTransport> transport, uint32_t sz, uint32_t bufReclaimThresh = (std::numeric_limits<uint32_t>::max)()) : transport_(transport), @@ -366,7 +366,7 @@ public: const uint8_t* borrowSlow(uint8_t* buf, uint32_t* len); - boost::shared_ptr<TTransport> getUnderlyingTransport() { return transport_; } + stdcxx::shared_ptr<TTransport> getUnderlyingTransport() { return transport_; } /* * TVirtualTransport provides a default implementation of readAll(). @@ -407,7 +407,7 @@ protected: this->write((uint8_t*)&pad, sizeof(pad)); } - boost::shared_ptr<TTransport> transport_; + stdcxx::shared_ptr<TTransport> transport_; uint32_t rBufSize_; uint32_t wBufSize_; @@ -430,8 +430,8 @@ public: /** * Wraps the transport into a framed one. */ - virtual boost::shared_ptr<TTransport> getTransport(boost::shared_ptr<TTransport> trans) { - return boost::shared_ptr<TTransport>(new TFramedTransport(trans)); + virtual stdcxx::shared_ptr<TTransport> getTransport(stdcxx::shared_ptr<TTransport> trans) { + return stdcxx::shared_ptr<TTransport>(new TFramedTransport(trans)); } }; diff --git a/lib/cpp/src/thrift/transport/TFDTransport.cpp b/lib/cpp/src/thrift/transport/TFDTransport.cpp index 4bce3a8f2..93dd10021 100644 --- a/lib/cpp/src/thrift/transport/TFDTransport.cpp +++ b/lib/cpp/src/thrift/transport/TFDTransport.cpp @@ -31,7 +31,7 @@ #include <io.h> #endif -using namespace std; +using std::string; namespace apache { namespace thrift { diff --git a/lib/cpp/src/thrift/transport/TFileTransport.cpp b/lib/cpp/src/thrift/transport/TFileTransport.cpp index e49f81c66..4683f9531 100644 --- a/lib/cpp/src/thrift/transport/TFileTransport.cpp +++ b/lib/cpp/src/thrift/transport/TFileTransport.cpp @@ -24,7 +24,6 @@ #include <thrift/transport/PlatformSocket.h> #include <thrift/concurrency/FunctionRunner.h> -#include <boost/scoped_ptr.hpp> #include <boost/version.hpp> #if (BOOST_VERSION >= 105700) #include <boost/move/unique_ptr.hpp> @@ -62,7 +61,7 @@ namespace apache { namespace thrift { namespace transport { -using boost::shared_ptr; +using stdcxx::shared_ptr; using std::cerr; using std::cout; using std::endl; @@ -853,7 +852,7 @@ void TFileTransport::seekToChunk(int32_t chunk) { uint32_t oldReadTimeout = getReadTimeout(); setReadTimeout(NO_TAIL_READ_TIMEOUT); // keep on reading unti the last event at point of seekChunk call - boost::scoped_ptr<eventInfo> event; + shared_ptr<eventInfo> event; while ((offset_ + readState_.bufferPtr_) < minEndOffset) { event.reset(readEvent()); if (event.get() == NULL) { diff --git a/lib/cpp/src/thrift/transport/TFileTransport.h b/lib/cpp/src/thrift/transport/TFileTransport.h index c926c7c5e..11674972f 100644 --- a/lib/cpp/src/thrift/transport/TFileTransport.h +++ b/lib/cpp/src/thrift/transport/TFileTransport.h @@ -28,8 +28,7 @@ #include <stdio.h> #include <boost/atomic.hpp> -#include <boost/scoped_ptr.hpp> -#include <boost/shared_ptr.hpp> +#include <thrift/stdcxx.h> #include <thrift/concurrency/Mutex.h> #include <thrift/concurrency/Monitor.h> @@ -340,7 +339,7 @@ private: // writer thread apache::thrift::concurrency::PlatformThreadFactory threadFactory_; - boost::shared_ptr<apache::thrift::concurrency::Thread> writerThread_; + stdcxx::shared_ptr<apache::thrift::concurrency::Thread> writerThread_; // buffers to hold data before it is flushed. Each element of the buffer stores a msg that // needs to be written to the file. The buffers are swapped by the writer thread. @@ -391,14 +390,14 @@ public: * @param protocolFactory protocol factory * @param inputTransport file transport */ - TFileProcessor(boost::shared_ptr<TProcessor> processor, - boost::shared_ptr<TProtocolFactory> protocolFactory, - boost::shared_ptr<TFileReaderTransport> inputTransport); + TFileProcessor(stdcxx::shared_ptr<TProcessor> processor, + stdcxx::shared_ptr<TProtocolFactory> protocolFactory, + stdcxx::shared_ptr<TFileReaderTransport> inputTransport); - TFileProcessor(boost::shared_ptr<TProcessor> processor, - boost::shared_ptr<TProtocolFactory> inputProtocolFactory, - boost::shared_ptr<TProtocolFactory> outputProtocolFactory, - boost::shared_ptr<TFileReaderTransport> inputTransport); + TFileProcessor(stdcxx::shared_ptr<TProcessor> processor, + stdcxx::shared_ptr<TProtocolFactory> inputProtocolFactory, + stdcxx::shared_ptr<TProtocolFactory> outputProtocolFactory, + stdcxx::shared_ptr<TFileReaderTransport> inputTransport); /** * Constructor @@ -408,10 +407,10 @@ public: * @param inputTransport input file transport * @param output output transport */ - TFileProcessor(boost::shared_ptr<TProcessor> processor, - boost::shared_ptr<TProtocolFactory> protocolFactory, - boost::shared_ptr<TFileReaderTransport> inputTransport, - boost::shared_ptr<TTransport> outputTransport); + TFileProcessor(stdcxx::shared_ptr<TProcessor> processor, + stdcxx::shared_ptr<TProtocolFactory> protocolFactory, + stdcxx::shared_ptr<TFileReaderTransport> inputTransport, + stdcxx::shared_ptr<TTransport> outputTransport); /** * processes events from the file @@ -428,11 +427,11 @@ public: void processChunk(); private: - boost::shared_ptr<TProcessor> processor_; - boost::shared_ptr<TProtocolFactory> inputProtocolFactory_; - boost::shared_ptr<TProtocolFactory> outputProtocolFactory_; - boost::shared_ptr<TFileReaderTransport> inputTransport_; - boost::shared_ptr<TTransport> outputTransport_; + stdcxx::shared_ptr<TProcessor> processor_; + stdcxx::shared_ptr<TProtocolFactory> inputProtocolFactory_; + stdcxx::shared_ptr<TProtocolFactory> outputProtocolFactory_; + stdcxx::shared_ptr<TFileReaderTransport> inputTransport_; + stdcxx::shared_ptr<TTransport> outputTransport_; }; } } diff --git a/lib/cpp/src/thrift/transport/THeaderTransport.cpp b/lib/cpp/src/thrift/transport/THeaderTransport.cpp index f222910c6..1a687da88 100644 --- a/lib/cpp/src/thrift/transport/THeaderTransport.cpp +++ b/lib/cpp/src/thrift/transport/THeaderTransport.cpp @@ -22,6 +22,7 @@ #include <thrift/protocol/TProtocolTypes.h> #include <thrift/protocol/TBinaryProtocol.h> #include <thrift/protocol/TCompactProtocol.h> +#include <thrift/stdcxx.h> #include <limits> #include <utility> @@ -30,12 +31,14 @@ #include <zlib.h> using std::map; -using boost::shared_ptr; using std::string; using std::vector; namespace apache { namespace thrift { + +using stdcxx::shared_ptr; + namespace transport { using namespace apache::thrift::protocol; @@ -255,7 +258,7 @@ void THeaderTransport::readHeaderFormat(uint16_t headerSize, uint32_t sz) { } // Untransform the data section. rBuf will contain result. - untransform(data, safe_numeric_cast<uint32_t>(static_cast<ptrdiff_t>(sz) - (data - rBuf_.get()))); + untransform(data, safe_numeric_cast<uint32_t>(static_cast<ptrdiff_t>(sz) - (data - rBuf_.get()))); } void THeaderTransport::untransform(uint8_t* ptr, uint32_t sz) { diff --git a/lib/cpp/src/thrift/transport/THeaderTransport.h b/lib/cpp/src/thrift/transport/THeaderTransport.h index af20fe39a..1a2c8e049 100644 --- a/lib/cpp/src/thrift/transport/THeaderTransport.h +++ b/lib/cpp/src/thrift/transport/THeaderTransport.h @@ -34,7 +34,7 @@ #endif #include <boost/scoped_array.hpp> -#include <boost/shared_ptr.hpp> +#include <thrift/stdcxx.h> #include <thrift/protocol/TProtocolTypes.h> #include <thrift/transport/TBufferTransports.h> @@ -75,7 +75,7 @@ public: static const int THRIFT_MAX_VARINT32_BYTES = 5; /// Use default buffer sizes. - explicit THeaderTransport(const boost::shared_ptr<TTransport>& transport) + explicit THeaderTransport(const stdcxx::shared_ptr<TTransport>& transport) : TVirtualTransport(transport), outTransport_(transport), protoId(T_COMPACT_PROTOCOL), @@ -88,8 +88,8 @@ public: initBuffers(); } - THeaderTransport(const boost::shared_ptr<TTransport> inTransport, - const boost::shared_ptr<TTransport> outTransport) + THeaderTransport(const stdcxx::shared_ptr<TTransport> inTransport, + const stdcxx::shared_ptr<TTransport> outTransport) : TVirtualTransport(inTransport), outTransport_(outTransport), protoId(T_COMPACT_PROTOCOL), @@ -186,7 +186,7 @@ protected: setWriteBuffer(wBuf_.get(), wBufSize_); } - boost::shared_ptr<TTransport> outTransport_; + stdcxx::shared_ptr<TTransport> outTransport_; // 0 and 16th bits must be 0 to differentiate from framed & unframed static const uint32_t HEADER_MAGIC = 0x0FFF0000; @@ -265,8 +265,8 @@ public: /** * Wraps the transport into a header one. */ - virtual boost::shared_ptr<TTransport> getTransport(boost::shared_ptr<TTransport> trans) { - return boost::shared_ptr<TTransport>(new THeaderTransport(trans)); + virtual stdcxx::shared_ptr<TTransport> getTransport(stdcxx::shared_ptr<TTransport> trans) { + return stdcxx::shared_ptr<TTransport>(new THeaderTransport(trans)); } }; } diff --git a/lib/cpp/src/thrift/transport/THttpClient.cpp b/lib/cpp/src/thrift/transport/THttpClient.cpp index 732c7e4b4..afd02a83d 100644 --- a/lib/cpp/src/thrift/transport/THttpClient.cpp +++ b/lib/cpp/src/thrift/transport/THttpClient.cpp @@ -26,20 +26,20 @@ #include <thrift/transport/THttpClient.h> #include <thrift/transport/TSocket.h> +using std::string; + namespace apache { namespace thrift { namespace transport { -using namespace std; - -THttpClient::THttpClient(boost::shared_ptr<TTransport> transport, +THttpClient::THttpClient(stdcxx::shared_ptr<TTransport> transport, std::string host, std::string path) : THttpTransport(transport), host_(host), path_(path) { } THttpClient::THttpClient(string host, int port, string path) - : THttpTransport(boost::shared_ptr<TTransport>(new TSocket(host, port))), + : THttpTransport(stdcxx::shared_ptr<TTransport>(new TSocket(host, port))), host_(host), path_(path) { } diff --git a/lib/cpp/src/thrift/transport/THttpClient.h b/lib/cpp/src/thrift/transport/THttpClient.h index 64e733259..96fd5b846 100644 --- a/lib/cpp/src/thrift/transport/THttpClient.h +++ b/lib/cpp/src/thrift/transport/THttpClient.h @@ -28,7 +28,7 @@ namespace transport { class THttpClient : public THttpTransport { public: - THttpClient(boost::shared_ptr<TTransport> transport, std::string host, std::string path = ""); + THttpClient(stdcxx::shared_ptr<TTransport> transport, std::string host, std::string path = ""); THttpClient(std::string host, int port, std::string path = ""); diff --git a/lib/cpp/src/thrift/transport/THttpServer.cpp b/lib/cpp/src/thrift/transport/THttpServer.cpp index ae3a171b2..2f48cf6dd 100644 --- a/lib/cpp/src/thrift/transport/THttpServer.cpp +++ b/lib/cpp/src/thrift/transport/THttpServer.cpp @@ -28,13 +28,13 @@ #include <Shlwapi.h> #endif +using std::string; + namespace apache { namespace thrift { namespace transport { -using namespace std; - -THttpServer::THttpServer(boost::shared_ptr<TTransport> transport) : THttpTransport(transport) { +THttpServer::THttpServer(stdcxx::shared_ptr<TTransport> transport) : THttpTransport(transport) { } THttpServer::~THttpServer() { diff --git a/lib/cpp/src/thrift/transport/THttpServer.h b/lib/cpp/src/thrift/transport/THttpServer.h index a7ab94406..086dd6f5f 100644 --- a/lib/cpp/src/thrift/transport/THttpServer.h +++ b/lib/cpp/src/thrift/transport/THttpServer.h @@ -28,7 +28,7 @@ namespace transport { class THttpServer : public THttpTransport { public: - THttpServer(boost::shared_ptr<TTransport> transport); + THttpServer(stdcxx::shared_ptr<TTransport> transport); virtual ~THttpServer(); @@ -53,8 +53,8 @@ public: /** * Wraps the transport into a buffered one. */ - virtual boost::shared_ptr<TTransport> getTransport(boost::shared_ptr<TTransport> trans) { - return boost::shared_ptr<TTransport>(new THttpServer(trans)); + virtual stdcxx::shared_ptr<TTransport> getTransport(stdcxx::shared_ptr<TTransport> trans) { + return stdcxx::shared_ptr<TTransport>(new THttpServer(trans)); } }; } diff --git a/lib/cpp/src/thrift/transport/THttpTransport.cpp b/lib/cpp/src/thrift/transport/THttpTransport.cpp index f93df2386..c97f6d3ac 100644 --- a/lib/cpp/src/thrift/transport/THttpTransport.cpp +++ b/lib/cpp/src/thrift/transport/THttpTransport.cpp @@ -21,17 +21,17 @@ #include <thrift/transport/THttpTransport.h> +using std::string; + namespace apache { namespace thrift { namespace transport { -using namespace std; - // Yeah, yeah, hacky to put these here, I know. const char* THttpTransport::CRLF = "\r\n"; const int THttpTransport::CRLF_LEN = 2; -THttpTransport::THttpTransport(boost::shared_ptr<TTransport> transport) +THttpTransport::THttpTransport(stdcxx::shared_ptr<TTransport> transport) : transport_(transport), origin_(""), readHeaders_(true), diff --git a/lib/cpp/src/thrift/transport/THttpTransport.h b/lib/cpp/src/thrift/transport/THttpTransport.h index a9f564c48..3fa80f81d 100644 --- a/lib/cpp/src/thrift/transport/THttpTransport.h +++ b/lib/cpp/src/thrift/transport/THttpTransport.h @@ -36,7 +36,7 @@ namespace transport { */ class THttpTransport : public TVirtualTransport<THttpTransport> { public: - THttpTransport(boost::shared_ptr<TTransport> transport); + THttpTransport(stdcxx::shared_ptr<TTransport> transport); virtual ~THttpTransport(); @@ -59,7 +59,7 @@ public: virtual const std::string getOrigin(); protected: - boost::shared_ptr<TTransport> transport_; + stdcxx::shared_ptr<TTransport> transport_; std::string origin_; TMemoryBuffer writeBuffer_; diff --git a/lib/cpp/src/thrift/transport/TNonblockingSSLServerSocket.cpp b/lib/cpp/src/thrift/transport/TNonblockingSSLServerSocket.cpp index 8e8b897a3..da83bea14 100644 --- a/lib/cpp/src/thrift/transport/TNonblockingSSLServerSocket.cpp +++ b/lib/cpp/src/thrift/transport/TNonblockingSSLServerSocket.cpp @@ -27,14 +27,14 @@ namespace transport { /** * Nonblocking SSL server socket implementation. */ -TNonblockingSSLServerSocket::TNonblockingSSLServerSocket(int port, boost::shared_ptr<TSSLSocketFactory> factory) +TNonblockingSSLServerSocket::TNonblockingSSLServerSocket(int port, stdcxx::shared_ptr<TSSLSocketFactory> factory) : TNonblockingServerSocket(port), factory_(factory) { factory_->server(true); } TNonblockingSSLServerSocket::TNonblockingSSLServerSocket(const std::string& address, int port, - boost::shared_ptr<TSSLSocketFactory> factory) + stdcxx::shared_ptr<TSSLSocketFactory> factory) : TNonblockingServerSocket(address, port), factory_(factory) { factory_->server(true); } @@ -42,13 +42,13 @@ TNonblockingSSLServerSocket::TNonblockingSSLServerSocket(const std::string& addr TNonblockingSSLServerSocket::TNonblockingSSLServerSocket(int port, int sendTimeout, int recvTimeout, - boost::shared_ptr<TSSLSocketFactory> factory) + stdcxx::shared_ptr<TSSLSocketFactory> factory) : TNonblockingServerSocket(port, sendTimeout, recvTimeout), factory_(factory) { factory_->server(true); } -boost::shared_ptr<TSocket> TNonblockingSSLServerSocket::createSocket(THRIFT_SOCKET client) { - boost::shared_ptr<TSSLSocket> tSSLSocket; +stdcxx::shared_ptr<TSocket> TNonblockingSSLServerSocket::createSocket(THRIFT_SOCKET client) { + stdcxx::shared_ptr<TSSLSocket> tSSLSocket; tSSLSocket = factory_->createSocket(client); tSSLSocket->setLibeventSafe(); return tSSLSocket; diff --git a/lib/cpp/src/thrift/transport/TNonblockingSSLServerSocket.h b/lib/cpp/src/thrift/transport/TNonblockingSSLServerSocket.h index 66a8a700a..7aaff53df 100644 --- a/lib/cpp/src/thrift/transport/TNonblockingSSLServerSocket.h +++ b/lib/cpp/src/thrift/transport/TNonblockingSSLServerSocket.h @@ -20,8 +20,8 @@ #ifndef _THRIFT_TRANSPORT_TNONBLOCKINGSSLSERVERSOCKET_H_ #define _THRIFT_TRANSPORT_TNONBLOCKINGSSLSERVERSOCKET_H_ 1 -#include <boost/shared_ptr.hpp> #include <thrift/transport/TNonblockingServerSocket.h> +#include <thrift/stdcxx.h> namespace apache { namespace thrift { @@ -40,7 +40,7 @@ public: * @param port Listening port * @param factory SSL socket factory implementation */ - TNonblockingSSLServerSocket(int port, boost::shared_ptr<TSSLSocketFactory> factory); + TNonblockingSSLServerSocket(int port, stdcxx::shared_ptr<TSSLSocketFactory> factory); /** * Constructor. Binds to the specified address. @@ -51,7 +51,7 @@ public: */ TNonblockingSSLServerSocket(const std::string& address, int port, - boost::shared_ptr<TSSLSocketFactory> factory); + stdcxx::shared_ptr<TSSLSocketFactory> factory); /** * Constructor. Binds to all interfaces. @@ -64,11 +64,11 @@ public: TNonblockingSSLServerSocket(int port, int sendTimeout, int recvTimeout, - boost::shared_ptr<TSSLSocketFactory> factory); + stdcxx::shared_ptr<TSSLSocketFactory> factory); protected: - boost::shared_ptr<TSocket> createSocket(THRIFT_SOCKET socket); - boost::shared_ptr<TSSLSocketFactory> factory_; + stdcxx::shared_ptr<TSocket> createSocket(THRIFT_SOCKET socket); + stdcxx::shared_ptr<TSSLSocketFactory> factory_; }; } } diff --git a/lib/cpp/src/thrift/transport/TNonblockingServerSocket.cpp b/lib/cpp/src/thrift/transport/TNonblockingServerSocket.cpp index 73a458b75..89073e1d5 100644 --- a/lib/cpp/src/thrift/transport/TNonblockingServerSocket.cpp +++ b/lib/cpp/src/thrift/transport/TNonblockingServerSocket.cpp @@ -46,7 +46,6 @@ #include <thrift/transport/TSocket.h> #include <thrift/transport/TNonblockingServerSocket.h> #include <thrift/transport/PlatformSocket.h> -#include <boost/shared_ptr.hpp> #ifndef AF_LOCAL #define AF_LOCAL AF_UNIX @@ -74,8 +73,8 @@ namespace apache { namespace thrift { namespace transport { -using namespace std; -using boost::shared_ptr; +using std::string; +using stdcxx::shared_ptr; TNonblockingServerSocket::TNonblockingServerSocket(int port) : port_(port), diff --git a/lib/cpp/src/thrift/transport/TNonblockingServerSocket.h b/lib/cpp/src/thrift/transport/TNonblockingServerSocket.h index ff88ecb07..1d33239ff 100644 --- a/lib/cpp/src/thrift/transport/TNonblockingServerSocket.h +++ b/lib/cpp/src/thrift/transport/TNonblockingServerSocket.h @@ -22,8 +22,7 @@ #include <thrift/transport/TNonblockingServerTransport.h> #include <thrift/transport/PlatformSocket.h> -#include <thrift/cxxfunctional.h> -#include <boost/shared_ptr.hpp> +#include <thrift/stdcxx.h> namespace apache { namespace thrift { @@ -109,8 +108,8 @@ public: void close(); protected: - boost::shared_ptr<TSocket> acceptImpl(); - virtual boost::shared_ptr<TSocket> createSocket(THRIFT_SOCKET client); + apache::thrift::stdcxx::shared_ptr<TSocket> acceptImpl(); + virtual apache::thrift::stdcxx::shared_ptr<TSocket> createSocket(THRIFT_SOCKET client); private: int port_; diff --git a/lib/cpp/src/thrift/transport/TNonblockingServerTransport.h b/lib/cpp/src/thrift/transport/TNonblockingServerTransport.h index 21b826214..c32a051d9 100644 --- a/lib/cpp/src/thrift/transport/TNonblockingServerTransport.h +++ b/lib/cpp/src/thrift/transport/TNonblockingServerTransport.h @@ -22,7 +22,7 @@ #include <thrift/transport/TSocket.h> #include <thrift/transport/TTransportException.h> -#include <boost/shared_ptr.hpp> +#include <thrift/stdcxx.h> namespace apache { namespace thrift { @@ -56,8 +56,8 @@ public: * @return A new TTransport object * @throws TTransportException if there is an error */ - boost::shared_ptr<TSocket> accept() { - boost::shared_ptr<TSocket> result = acceptImpl(); + stdcxx::shared_ptr<TSocket> accept() { + stdcxx::shared_ptr<TSocket> result = acceptImpl(); if (!result) { throw TTransportException("accept() may not return NULL"); } @@ -91,7 +91,7 @@ protected: * @return A newly allocated TTransport object * @throw TTransportException If an error occurs */ - virtual boost::shared_ptr<TSocket> acceptImpl() = 0; + virtual stdcxx::shared_ptr<TSocket> acceptImpl() = 0; }; } diff --git a/lib/cpp/src/thrift/transport/TPipe.cpp b/lib/cpp/src/thrift/transport/TPipe.cpp index 0f489034b..8a84457db 100644 --- a/lib/cpp/src/thrift/transport/TPipe.cpp +++ b/lib/cpp/src/thrift/transport/TPipe.cpp @@ -28,8 +28,6 @@ namespace apache { namespace thrift { namespace transport { -using namespace std; - /** * TPipe implementation. */ @@ -160,7 +158,8 @@ uint32_t TWaitableNamedPipeImpl::read(uint8_t* buf, uint32_t len) { end_unread_idx_ = endAsyncRead(); } - uint32_t bytes_to_copy = (std::min)(len, end_unread_idx_ - begin_unread_idx_); + uint32_t __idxsize = end_unread_idx_ - begin_unread_idx_; + uint32_t bytes_to_copy = (len < __idxsize) ? len : __idxsize; memcpy(buf, &buffer_[begin_unread_idx_], bytes_to_copy); begin_unread_idx_ += bytes_to_copy; if (begin_unread_idx_ != end_unread_idx_) { @@ -341,7 +340,7 @@ void pipe_write(HANDLE pipe, const uint8_t* buf, uint32_t len) { // Accessors //--------------------------------------------------------- -string TPipe::getPipename() { +std::string TPipe::getPipename() { return pipename_; } diff --git a/lib/cpp/src/thrift/transport/TPipe.h b/lib/cpp/src/thrift/transport/TPipe.h index 5dd8f9a24..dfc5f2c2f 100644 --- a/lib/cpp/src/thrift/transport/TPipe.h +++ b/lib/cpp/src/thrift/transport/TPipe.h @@ -95,7 +95,7 @@ public: HANDLE getNativeWaitHandle(); private: - boost::shared_ptr<TPipeImpl> impl_; + stdcxx::shared_ptr<TPipeImpl> impl_; std::string pipename_; diff --git a/lib/cpp/src/thrift/transport/TPipeServer.cpp b/lib/cpp/src/thrift/transport/TPipeServer.cpp index 5a07f3085..3bceadf0a 100644 --- a/lib/cpp/src/thrift/transport/TPipeServer.cpp +++ b/lib/cpp/src/thrift/transport/TPipeServer.cpp @@ -22,7 +22,7 @@ #include <thrift/transport/TPipe.h> #include <thrift/transport/TPipeServer.h> -#include <boost/shared_ptr.hpp> +#include <thrift/stdcxx.h> #include <boost/noncopyable.hpp> #ifdef _WIN32 @@ -37,15 +37,14 @@ namespace transport { #ifdef _WIN32 -using namespace std; -using boost::shared_ptr; +using stdcxx::shared_ptr; class TPipeServerImpl : boost::noncopyable { public: TPipeServerImpl() {} virtual ~TPipeServerImpl() {} virtual void interrupt() = 0; - virtual boost::shared_ptr<TTransport> acceptImpl() = 0; + virtual stdcxx::shared_ptr<TTransport> acceptImpl() = 0; virtual HANDLE getPipeHandle() = 0; virtual HANDLE getWrtPipeHandle() = 0; @@ -76,7 +75,7 @@ public: virtual void interrupt() {} // not currently implemented - virtual boost::shared_ptr<TTransport> acceptImpl(); + virtual stdcxx::shared_ptr<TTransport> acceptImpl(); virtual HANDLE getPipeHandle() { return PipeR_.h; } virtual HANDLE getWrtPipeHandle() { return PipeW_.h; } @@ -118,7 +117,7 @@ public: } } - virtual boost::shared_ptr<TTransport> acceptImpl(); + virtual stdcxx::shared_ptr<TTransport> acceptImpl(); virtual HANDLE getPipeHandle() { return Pipe_.h; } virtual HANDLE getWrtPipeHandle() { return INVALID_HANDLE_VALUE; } @@ -142,7 +141,7 @@ private: TCriticalSection pipe_protect_; // only read or write these variables underneath a locked pipe_protect_ - boost::shared_ptr<TPipe> cached_client_; + stdcxx::shared_ptr<TPipe> cached_client_; TAutoHandle Pipe_; }; @@ -404,7 +403,7 @@ bool TAnonPipeServer::createAnonPipe() { //--------------------------------------------------------- // Accessors //--------------------------------------------------------- -string TPipeServer::getPipename() { +std::string TPipeServer::getPipename() { return pipename_; } diff --git a/lib/cpp/src/thrift/transport/TPipeServer.h b/lib/cpp/src/thrift/transport/TPipeServer.h index 405793e7d..117773c22 100644 --- a/lib/cpp/src/thrift/transport/TPipeServer.h +++ b/lib/cpp/src/thrift/transport/TPipeServer.h @@ -21,7 +21,7 @@ #define _THRIFT_TRANSPORT_TSERVERWINPIPES_H_ 1 #include <thrift/transport/TServerTransport.h> -#include <boost/shared_ptr.hpp> +#include <thrift/stdcxx.h> #ifndef _WIN32 #include <thrift/transport/TServerSocket.h> #endif @@ -82,10 +82,10 @@ public: HANDLE getNativeWaitHandle(); protected: - virtual boost::shared_ptr<TTransport> acceptImpl(); + virtual stdcxx::shared_ptr<TTransport> acceptImpl(); private: - boost::shared_ptr<TPipeServerImpl> impl_; + stdcxx::shared_ptr<TPipeServerImpl> impl_; std::string pipename_; uint32_t bufsize_; diff --git a/lib/cpp/src/thrift/transport/TSSLServerSocket.cpp b/lib/cpp/src/thrift/transport/TSSLServerSocket.cpp index 89423b453..8e81ad743 100644 --- a/lib/cpp/src/thrift/transport/TSSLServerSocket.cpp +++ b/lib/cpp/src/thrift/transport/TSSLServerSocket.cpp @@ -27,14 +27,14 @@ namespace transport { /** * SSL server socket implementation. */ -TSSLServerSocket::TSSLServerSocket(int port, boost::shared_ptr<TSSLSocketFactory> factory) +TSSLServerSocket::TSSLServerSocket(int port, stdcxx::shared_ptr<TSSLSocketFactory> factory) : TServerSocket(port), factory_(factory) { factory_->server(true); } TSSLServerSocket::TSSLServerSocket(const std::string& address, int port, - boost::shared_ptr<TSSLSocketFactory> factory) + stdcxx::shared_ptr<TSSLSocketFactory> factory) : TServerSocket(address, port), factory_(factory) { factory_->server(true); } @@ -42,12 +42,12 @@ TSSLServerSocket::TSSLServerSocket(const std::string& address, TSSLServerSocket::TSSLServerSocket(int port, int sendTimeout, int recvTimeout, - boost::shared_ptr<TSSLSocketFactory> factory) + stdcxx::shared_ptr<TSSLSocketFactory> factory) : TServerSocket(port, sendTimeout, recvTimeout), factory_(factory) { factory_->server(true); } -boost::shared_ptr<TSocket> TSSLServerSocket::createSocket(THRIFT_SOCKET client) { +stdcxx::shared_ptr<TSocket> TSSLServerSocket::createSocket(THRIFT_SOCKET client) { if (interruptableChildren_) { return factory_->createSocket(client, pChildInterruptSockReader_); diff --git a/lib/cpp/src/thrift/transport/TSSLServerSocket.h b/lib/cpp/src/thrift/transport/TSSLServerSocket.h index dfdbde85c..dda9af417 100644 --- a/lib/cpp/src/thrift/transport/TSSLServerSocket.h +++ b/lib/cpp/src/thrift/transport/TSSLServerSocket.h @@ -20,7 +20,7 @@ #ifndef _THRIFT_TRANSPORT_TSSLSERVERSOCKET_H_ #define _THRIFT_TRANSPORT_TSSLSERVERSOCKET_H_ 1 -#include <boost/shared_ptr.hpp> +#include <thrift/stdcxx.h> #include <thrift/transport/TServerSocket.h> namespace apache { @@ -40,7 +40,7 @@ public: * @param port Listening port * @param factory SSL socket factory implementation */ - TSSLServerSocket(int port, boost::shared_ptr<TSSLSocketFactory> factory); + TSSLServerSocket(int port, stdcxx::shared_ptr<TSSLSocketFactory> factory); /** * Constructor. Binds to the specified address. @@ -51,7 +51,7 @@ public: */ TSSLServerSocket(const std::string& address, int port, - boost::shared_ptr<TSSLSocketFactory> factory); + stdcxx::shared_ptr<TSSLSocketFactory> factory); /** * Constructor. Binds to all interfaces. @@ -64,11 +64,11 @@ public: TSSLServerSocket(int port, int sendTimeout, int recvTimeout, - boost::shared_ptr<TSSLSocketFactory> factory); + stdcxx::shared_ptr<TSSLSocketFactory> factory); protected: - boost::shared_ptr<TSocket> createSocket(THRIFT_SOCKET socket); - boost::shared_ptr<TSSLSocketFactory> factory_; + stdcxx::shared_ptr<TSocket> createSocket(THRIFT_SOCKET socket); + stdcxx::shared_ptr<TSSLSocketFactory> factory_; }; } } diff --git a/lib/cpp/src/thrift/transport/TSSLSocket.cpp b/lib/cpp/src/thrift/transport/TSSLSocket.cpp index e8f38dd6c..d8b16e115 100644 --- a/lib/cpp/src/thrift/transport/TSSLSocket.cpp +++ b/lib/cpp/src/thrift/transport/TSSLSocket.cpp @@ -52,8 +52,8 @@ #include <thrift/transport/PlatformSocket.h> #include <thrift/TToString.h> -using namespace std; using namespace apache::thrift::concurrency; +using std::string; struct CRYPTO_dynlock_value { Mutex mutex; @@ -212,33 +212,33 @@ SSL* SSLContext::createSSL() { } // TSSLSocket implementation -TSSLSocket::TSSLSocket(boost::shared_ptr<SSLContext> ctx) +TSSLSocket::TSSLSocket(stdcxx::shared_ptr<SSLContext> ctx) : TSocket(), server_(false), ssl_(NULL), ctx_(ctx) { init(); } -TSSLSocket::TSSLSocket(boost::shared_ptr<SSLContext> ctx, boost::shared_ptr<THRIFT_SOCKET> interruptListener) +TSSLSocket::TSSLSocket(stdcxx::shared_ptr<SSLContext> ctx, stdcxx::shared_ptr<THRIFT_SOCKET> interruptListener) : TSocket(), server_(false), ssl_(NULL), ctx_(ctx) { init(); interruptListener_ = interruptListener; } -TSSLSocket::TSSLSocket(boost::shared_ptr<SSLContext> ctx, THRIFT_SOCKET socket) +TSSLSocket::TSSLSocket(stdcxx::shared_ptr<SSLContext> ctx, THRIFT_SOCKET socket) : TSocket(socket), server_(false), ssl_(NULL), ctx_(ctx) { init(); } -TSSLSocket::TSSLSocket(boost::shared_ptr<SSLContext> ctx, THRIFT_SOCKET socket, boost::shared_ptr<THRIFT_SOCKET> interruptListener) +TSSLSocket::TSSLSocket(stdcxx::shared_ptr<SSLContext> ctx, THRIFT_SOCKET socket, stdcxx::shared_ptr<THRIFT_SOCKET> interruptListener) : TSocket(socket, interruptListener), server_(false), ssl_(NULL), ctx_(ctx) { init(); } -TSSLSocket::TSSLSocket(boost::shared_ptr<SSLContext> ctx, string host, int port) +TSSLSocket::TSSLSocket(stdcxx::shared_ptr<SSLContext> ctx, string host, int port) : TSocket(host, port), server_(false), ssl_(NULL), ctx_(ctx) { init(); } -TSSLSocket::TSSLSocket(boost::shared_ptr<SSLContext> ctx, string host, int port, boost::shared_ptr<THRIFT_SOCKET> interruptListener) +TSSLSocket::TSSLSocket(stdcxx::shared_ptr<SSLContext> ctx, string host, int port, stdcxx::shared_ptr<THRIFT_SOCKET> interruptListener) : TSocket(host, port), server_(false), ssl_(NULL), ctx_(ctx) { init(); interruptListener_ = interruptListener; @@ -807,7 +807,7 @@ TSSLSocketFactory::TSSLSocketFactory(SSLProtocol protocol) : server_(false) { randomize(); } count_++; - ctx_ = boost::shared_ptr<SSLContext>(new SSLContext(protocol)); + ctx_ = stdcxx::shared_ptr<SSLContext>(new SSLContext(protocol)); } TSSLSocketFactory::~TSSLSocketFactory() { @@ -819,47 +819,47 @@ TSSLSocketFactory::~TSSLSocketFactory() { } } -boost::shared_ptr<TSSLSocket> TSSLSocketFactory::createSocket() { - boost::shared_ptr<TSSLSocket> ssl(new TSSLSocket(ctx_)); +stdcxx::shared_ptr<TSSLSocket> TSSLSocketFactory::createSocket() { + stdcxx::shared_ptr<TSSLSocket> ssl(new TSSLSocket(ctx_)); setup(ssl); return ssl; } -boost::shared_ptr<TSSLSocket> TSSLSocketFactory::createSocket(boost::shared_ptr<THRIFT_SOCKET> interruptListener) { - boost::shared_ptr<TSSLSocket> ssl(new TSSLSocket(ctx_, interruptListener)); +stdcxx::shared_ptr<TSSLSocket> TSSLSocketFactory::createSocket(stdcxx::shared_ptr<THRIFT_SOCKET> interruptListener) { + stdcxx::shared_ptr<TSSLSocket> ssl(new TSSLSocket(ctx_, interruptListener)); setup(ssl); return ssl; } -boost::shared_ptr<TSSLSocket> TSSLSocketFactory::createSocket(THRIFT_SOCKET socket) { - boost::shared_ptr<TSSLSocket> ssl(new TSSLSocket(ctx_, socket)); +stdcxx::shared_ptr<TSSLSocket> TSSLSocketFactory::createSocket(THRIFT_SOCKET socket) { + stdcxx::shared_ptr<TSSLSocket> ssl(new TSSLSocket(ctx_, socket)); setup(ssl); return ssl; } -boost::shared_ptr<TSSLSocket> TSSLSocketFactory::createSocket(THRIFT_SOCKET socket, boost::shared_ptr<THRIFT_SOCKET> interruptListener) { - boost::shared_ptr<TSSLSocket> ssl(new TSSLSocket(ctx_, socket, interruptListener)); +stdcxx::shared_ptr<TSSLSocket> TSSLSocketFactory::createSocket(THRIFT_SOCKET socket, stdcxx::shared_ptr<THRIFT_SOCKET> interruptListener) { + stdcxx::shared_ptr<TSSLSocket> ssl(new TSSLSocket(ctx_, socket, interruptListener)); setup(ssl); return ssl; } -boost::shared_ptr<TSSLSocket> TSSLSocketFactory::createSocket(const string& host, int port) { - boost::shared_ptr<TSSLSocket> ssl(new TSSLSocket(ctx_, host, port)); +stdcxx::shared_ptr<TSSLSocket> TSSLSocketFactory::createSocket(const string& host, int port) { + stdcxx::shared_ptr<TSSLSocket> ssl(new TSSLSocket(ctx_, host, port)); setup(ssl); return ssl; } -boost::shared_ptr<TSSLSocket> TSSLSocketFactory::createSocket(const string& host, int port, boost::shared_ptr<THRIFT_SOCKET> interruptListener) { - boost::shared_ptr<TSSLSocket> ssl(new TSSLSocket(ctx_, host, port, interruptListener)); +stdcxx::shared_ptr<TSSLSocket> TSSLSocketFactory::createSocket(const string& host, int port, stdcxx::shared_ptr<THRIFT_SOCKET> interruptListener) { + stdcxx::shared_ptr<TSSLSocket> ssl(new TSSLSocket(ctx_, host, port, interruptListener)); setup(ssl); return ssl; } -void TSSLSocketFactory::setup(boost::shared_ptr<TSSLSocket> ssl) { +void TSSLSocketFactory::setup(stdcxx::shared_ptr<TSSLSocket> ssl) { ssl->server(server()); if (access_ == NULL && !server()) { - access_ = boost::shared_ptr<AccessManager>(new DefaultClientAccessManager); + access_ = stdcxx::shared_ptr<AccessManager>(new DefaultClientAccessManager); } if (access_ != NULL) { ssl->access(access_); diff --git a/lib/cpp/src/thrift/transport/TSSLSocket.h b/lib/cpp/src/thrift/transport/TSSLSocket.h index 023db9465..852720930 100644 --- a/lib/cpp/src/thrift/transport/TSSLSocket.h +++ b/lib/cpp/src/thrift/transport/TSSLSocket.h @@ -22,10 +22,11 @@ // Put this first to avoid WIN32 build failure #include <thrift/transport/TSocket.h> -#include <string> -#include <boost/shared_ptr.hpp> + #include <openssl/ssl.h> +#include <string> #include <thrift/concurrency/Mutex.h> +#include <thrift/stdcxx.h> namespace apache { namespace thrift { @@ -96,7 +97,7 @@ public: * * @param manager Instance of AccessManager */ - virtual void access(boost::shared_ptr<AccessManager> manager) { access_ = manager; } + virtual void access(stdcxx::shared_ptr<AccessManager> manager) { access_ = manager; } /** * Set eventSafe flag if libevent is used. */ @@ -110,37 +111,37 @@ protected: /** * Constructor. */ - TSSLSocket(boost::shared_ptr<SSLContext> ctx); + TSSLSocket(stdcxx::shared_ptr<SSLContext> ctx); /** * Constructor with an interrupt signal. */ - TSSLSocket(boost::shared_ptr<SSLContext> ctx, boost::shared_ptr<THRIFT_SOCKET> interruptListener); + TSSLSocket(stdcxx::shared_ptr<SSLContext> ctx, stdcxx::shared_ptr<THRIFT_SOCKET> interruptListener); /** * Constructor, create an instance of TSSLSocket given an existing socket. * * @param socket An existing socket */ - TSSLSocket(boost::shared_ptr<SSLContext> ctx, THRIFT_SOCKET socket); + TSSLSocket(stdcxx::shared_ptr<SSLContext> ctx, THRIFT_SOCKET socket); /** * Constructor, create an instance of TSSLSocket given an existing socket that can be interrupted. * * @param socket An existing socket */ - TSSLSocket(boost::shared_ptr<SSLContext> ctx, THRIFT_SOCKET socket, boost::shared_ptr<THRIFT_SOCKET> interruptListener); + TSSLSocket(stdcxx::shared_ptr<SSLContext> ctx, THRIFT_SOCKET socket, stdcxx::shared_ptr<THRIFT_SOCKET> interruptListener); /** * Constructor. * * @param host Remote host name * @param port Remote port number */ - TSSLSocket(boost::shared_ptr<SSLContext> ctx, std::string host, int port); + TSSLSocket(stdcxx::shared_ptr<SSLContext> ctx, std::string host, int port); /** * Constructor with an interrupt signal. * * @param host Remote host name * @param port Remote port number */ - TSSLSocket(boost::shared_ptr<SSLContext> ctx, std::string host, int port, boost::shared_ptr<THRIFT_SOCKET> interruptListener); + TSSLSocket(stdcxx::shared_ptr<SSLContext> ctx, std::string host, int port, stdcxx::shared_ptr<THRIFT_SOCKET> interruptListener); /** * Authorize peer access after SSL handshake completes. */ @@ -169,14 +170,14 @@ protected: bool server_; SSL* ssl_; - boost::shared_ptr<SSLContext> ctx_; - boost::shared_ptr<AccessManager> access_; + stdcxx::shared_ptr<SSLContext> ctx_; + stdcxx::shared_ptr<AccessManager> access_; friend class TSSLSocketFactory; private: bool handshakeCompleted_; int readRetryCount_; - bool eventSafe_; + bool eventSafe_; void init(); }; @@ -210,37 +211,37 @@ public: /** * Create an instance of TSSLSocket with a fresh new socket. */ - virtual boost::shared_ptr<TSSLSocket> createSocket(); + virtual stdcxx::shared_ptr<TSSLSocket> createSocket(); /** * Create an instance of TSSLSocket with a fresh new socket, which is interruptable. */ - virtual boost::shared_ptr<TSSLSocket> createSocket(boost::shared_ptr<THRIFT_SOCKET> interruptListener); + virtual stdcxx::shared_ptr<TSSLSocket> createSocket(stdcxx::shared_ptr<THRIFT_SOCKET> interruptListener); /** * Create an instance of TSSLSocket with the given socket. * * @param socket An existing socket. */ - virtual boost::shared_ptr<TSSLSocket> createSocket(THRIFT_SOCKET socket); + virtual stdcxx::shared_ptr<TSSLSocket> createSocket(THRIFT_SOCKET socket); /** * Create an instance of TSSLSocket with the given socket which is interruptable. * * @param socket An existing socket. */ - virtual boost::shared_ptr<TSSLSocket> createSocket(THRIFT_SOCKET socket, boost::shared_ptr<THRIFT_SOCKET> interruptListener); + virtual stdcxx::shared_ptr<TSSLSocket> createSocket(THRIFT_SOCKET socket, stdcxx::shared_ptr<THRIFT_SOCKET> interruptListener); /** * Create an instance of TSSLSocket. * * @param host Remote host to be connected to * @param port Remote port to be connected to */ - virtual boost::shared_ptr<TSSLSocket> createSocket(const std::string& host, int port); + virtual stdcxx::shared_ptr<TSSLSocket> createSocket(const std::string& host, int port); /** * Create an instance of TSSLSocket. * * @param host Remote host to be connected to * @param port Remote port to be connected to */ - virtual boost::shared_ptr<TSSLSocket> createSocket(const std::string& host, int port, boost::shared_ptr<THRIFT_SOCKET> interruptListener); + virtual stdcxx::shared_ptr<TSSLSocket> createSocket(const std::string& host, int port, stdcxx::shared_ptr<THRIFT_SOCKET> interruptListener); /** * Set ciphers to be used in SSL handshake process. * @@ -298,13 +299,13 @@ public: * * @param manager The AccessManager instance */ - virtual void access(boost::shared_ptr<AccessManager> manager) { access_ = manager; } + virtual void access(stdcxx::shared_ptr<AccessManager> manager) { access_ = manager; } static void setManualOpenSSLInitialization(bool manualOpenSSLInitialization) { manualOpenSSLInitialization_ = manualOpenSSLInitialization; } protected: - boost::shared_ptr<SSLContext> ctx_; + stdcxx::shared_ptr<SSLContext> ctx_; /** * Override this method for custom password callback. It may be called @@ -317,11 +318,11 @@ protected: private: bool server_; - boost::shared_ptr<AccessManager> access_; + stdcxx::shared_ptr<AccessManager> access_; static concurrency::Mutex mutex_; static uint64_t count_; static bool manualOpenSSLInitialization_; - void setup(boost::shared_ptr<TSSLSocket> ssl); + void setup(stdcxx::shared_ptr<TSSLSocket> ssl); static int passwordCallback(char* password, int size, int, void* data); }; diff --git a/lib/cpp/src/thrift/transport/TServerSocket.cpp b/lib/cpp/src/thrift/transport/TServerSocket.cpp index da869e0d6..a704b068c 100644 --- a/lib/cpp/src/thrift/transport/TServerSocket.cpp +++ b/lib/cpp/src/thrift/transport/TServerSocket.cpp @@ -46,7 +46,7 @@ #include <thrift/transport/TSocket.h> #include <thrift/transport/TServerSocket.h> #include <thrift/transport/PlatformSocket.h> -#include <boost/shared_ptr.hpp> +#include <thrift/stdcxx.h> #ifndef AF_LOCAL #define AF_LOCAL AF_UNIX @@ -75,12 +75,13 @@ void destroyer_of_fine_sockets(THRIFT_SOCKET* ssock) { delete ssock; } +using std::string; + namespace apache { namespace thrift { namespace transport { -using namespace std; -using boost::shared_ptr; +using stdcxx::shared_ptr; TGetAddrInfoWrapper::TGetAddrInfoWrapper(const char* node, const char* service, @@ -248,7 +249,7 @@ void TServerSocket::listen() { } else { childInterruptSockWriter_ = sv[1]; pChildInterruptSockReader_ - = boost::shared_ptr<THRIFT_SOCKET>(new THRIFT_SOCKET(sv[0]), destroyer_of_fine_sockets); + = stdcxx::shared_ptr<THRIFT_SOCKET>(new THRIFT_SOCKET(sv[0]), destroyer_of_fine_sockets); } // Validate port number diff --git a/lib/cpp/src/thrift/transport/TServerSocket.h b/lib/cpp/src/thrift/transport/TServerSocket.h index 58254ee26..cb11dc49a 100644 --- a/lib/cpp/src/thrift/transport/TServerSocket.h +++ b/lib/cpp/src/thrift/transport/TServerSocket.h @@ -20,10 +20,9 @@ #ifndef _THRIFT_TRANSPORT_TSERVERSOCKET_H_ #define _THRIFT_TRANSPORT_TSERVERSOCKET_H_ 1 -#include <thrift/transport/TServerTransport.h> +#include <thrift/stdcxx.h> #include <thrift/transport/PlatformSocket.h> -#include <thrift/cxxfunctional.h> -#include <boost/shared_ptr.hpp> +#include <thrift/transport/TServerTransport.h> #include <sys/types.h> #ifdef HAVE_SYS_SOCKET_H @@ -147,10 +146,10 @@ public: void close(); protected: - boost::shared_ptr<TTransport> acceptImpl(); - virtual boost::shared_ptr<TSocket> createSocket(THRIFT_SOCKET client); + stdcxx::shared_ptr<TTransport> acceptImpl(); + virtual stdcxx::shared_ptr<TSocket> createSocket(THRIFT_SOCKET client); bool interruptableChildren_; - boost::shared_ptr<THRIFT_SOCKET> pChildInterruptSockReader_; // if interruptableChildren_ this is shared with child TSockets + stdcxx::shared_ptr<THRIFT_SOCKET> pChildInterruptSockReader_; // if interruptableChildren_ this is shared with child TSockets private: void notify(THRIFT_SOCKET notifySock); diff --git a/lib/cpp/src/thrift/transport/TServerTransport.h b/lib/cpp/src/thrift/transport/TServerTransport.h index 51cb3e868..9d5a3d556 100644 --- a/lib/cpp/src/thrift/transport/TServerTransport.h +++ b/lib/cpp/src/thrift/transport/TServerTransport.h @@ -22,7 +22,7 @@ #include <thrift/transport/TTransport.h> #include <thrift/transport/TTransportException.h> -#include <boost/shared_ptr.hpp> +#include <thrift/stdcxx.h> namespace apache { namespace thrift { @@ -56,8 +56,8 @@ public: * @return A new TTransport object * @throws TTransportException if there is an error */ - boost::shared_ptr<TTransport> accept() { - boost::shared_ptr<TTransport> result = acceptImpl(); + stdcxx::shared_ptr<TTransport> accept() { + stdcxx::shared_ptr<TTransport> result = acceptImpl(); if (!result) { throw TTransportException("accept() may not return NULL"); } @@ -105,7 +105,7 @@ protected: * @return A newly allocated TTransport object * @throw TTransportException If an error occurs */ - virtual boost::shared_ptr<TTransport> acceptImpl() = 0; + virtual stdcxx::shared_ptr<TTransport> acceptImpl() = 0; }; } } diff --git a/lib/cpp/src/thrift/transport/TShortReadTransport.h b/lib/cpp/src/thrift/transport/TShortReadTransport.h index f2ecae132..550b6ba4b 100644 --- a/lib/cpp/src/thrift/transport/TShortReadTransport.h +++ b/lib/cpp/src/thrift/transport/TShortReadTransport.h @@ -38,7 +38,7 @@ namespace test { */ class TShortReadTransport : public TVirtualTransport<TShortReadTransport> { public: - TShortReadTransport(boost::shared_ptr<TTransport> transport, double full_prob) + TShortReadTransport(stdcxx::shared_ptr<TTransport> transport, double full_prob) : transport_(transport), fullProb_(full_prob) {} bool isOpen() { return transport_->isOpen(); } @@ -68,10 +68,10 @@ public: void consume(uint32_t len) { return transport_->consume(len); } - boost::shared_ptr<TTransport> getUnderlyingTransport() { return transport_; } + stdcxx::shared_ptr<TTransport> getUnderlyingTransport() { return transport_; } protected: - boost::shared_ptr<TTransport> transport_; + stdcxx::shared_ptr<TTransport> transport_; double fullProb_; }; } diff --git a/lib/cpp/src/thrift/transport/TSocket.cpp b/lib/cpp/src/thrift/transport/TSocket.cpp index 8f0f06ca8..7f8d7af78 100644 --- a/lib/cpp/src/thrift/transport/TSocket.cpp +++ b/lib/cpp/src/thrift/transport/TSocket.cpp @@ -63,12 +63,12 @@ inline SOCKOPT_CAST_T* cast_sockopt(T* v) { return reinterpret_cast<SOCKOPT_CAST_T*>(v); } +using std::string; + namespace apache { namespace thrift { namespace transport { -using namespace std; - /** * TSocket implementation. * @@ -141,7 +141,7 @@ TSocket::TSocket(THRIFT_SOCKET socket) #endif } -TSocket::TSocket(THRIFT_SOCKET socket, boost::shared_ptr<THRIFT_SOCKET> interruptListener) +TSocket::TSocket(THRIFT_SOCKET socket, stdcxx::shared_ptr<THRIFT_SOCKET> interruptListener) : port_(0), socket_(socket), peerPort_(0), diff --git a/lib/cpp/src/thrift/transport/TSocket.h b/lib/cpp/src/thrift/transport/TSocket.h index 69d2533d2..1f95e68bd 100644 --- a/lib/cpp/src/thrift/transport/TSocket.h +++ b/lib/cpp/src/thrift/transport/TSocket.h @@ -257,7 +257,7 @@ public: * Constructor to create socket from file descriptor that * can be interrupted safely. */ - TSocket(THRIFT_SOCKET socket, boost::shared_ptr<THRIFT_SOCKET> interruptListener); + TSocket(THRIFT_SOCKET socket, stdcxx::shared_ptr<THRIFT_SOCKET> interruptListener); /** * Set a cache of the peer address (used when trivially available: e.g. @@ -294,7 +294,7 @@ protected: * A shared socket pointer that will interrupt a blocking read if data * becomes available on it */ - boost::shared_ptr<THRIFT_SOCKET> interruptListener_; + stdcxx::shared_ptr<THRIFT_SOCKET> interruptListener_; /** Connect timeout in ms */ int connTimeout_; diff --git a/lib/cpp/src/thrift/transport/TSocketPool.cpp b/lib/cpp/src/thrift/transport/TSocketPool.cpp index ccab25803..963c69b47 100644 --- a/lib/cpp/src/thrift/transport/TSocketPool.cpp +++ b/lib/cpp/src/thrift/transport/TSocketPool.cpp @@ -24,13 +24,15 @@ #include <thrift/transport/TSocketPool.h> +using std::pair; +using std::string; +using std::vector; + namespace apache { namespace thrift { namespace transport { -using namespace std; - -using boost::shared_ptr; +using stdcxx::shared_ptr; /** * TSocketPoolServer implementation diff --git a/lib/cpp/src/thrift/transport/TSocketPool.h b/lib/cpp/src/thrift/transport/TSocketPool.h index 78f0ebfa2..bd49e5574 100644 --- a/lib/cpp/src/thrift/transport/TSocketPool.h +++ b/lib/cpp/src/thrift/transport/TSocketPool.h @@ -92,7 +92,7 @@ public: * * @param servers list of TSocketPoolServers */ - TSocketPool(const std::vector<boost::shared_ptr<TSocketPoolServer> >& servers); + TSocketPool(const std::vector<stdcxx::shared_ptr<TSocketPoolServer> >& servers); /** * Socket pool constructor @@ -115,17 +115,17 @@ public: /** * Add a server to the pool */ - void addServer(boost::shared_ptr<TSocketPoolServer>& server); + void addServer(stdcxx::shared_ptr<TSocketPoolServer>& server); /** * Set list of servers in this pool */ - void setServers(const std::vector<boost::shared_ptr<TSocketPoolServer> >& servers); + void setServers(const std::vector<stdcxx::shared_ptr<TSocketPoolServer> >& servers); /** * Get list of servers in this pool */ - void getServers(std::vector<boost::shared_ptr<TSocketPoolServer> >& servers); + void getServers(std::vector<stdcxx::shared_ptr<TSocketPoolServer> >& servers); /** * Sets how many times to keep retrying a host in the connect function. @@ -163,13 +163,13 @@ public: void close(); protected: - void setCurrentServer(const boost::shared_ptr<TSocketPoolServer>& server); + void setCurrentServer(const stdcxx::shared_ptr<TSocketPoolServer>& server); /** List of servers to connect to */ - std::vector<boost::shared_ptr<TSocketPoolServer> > servers_; + std::vector<stdcxx::shared_ptr<TSocketPoolServer> > servers_; /** Current server */ - boost::shared_ptr<TSocketPoolServer> currentServer_; + stdcxx::shared_ptr<TSocketPoolServer> currentServer_; /** How many times to retry each host in connect */ int numRetries_; diff --git a/lib/cpp/src/thrift/transport/TTransport.h b/lib/cpp/src/thrift/transport/TTransport.h index d06b0f882..de032909d 100644 --- a/lib/cpp/src/thrift/transport/TTransport.h +++ b/lib/cpp/src/thrift/transport/TTransport.h @@ -21,7 +21,7 @@ #define _THRIFT_TRANSPORT_TTRANSPORT_H_ 1 #include <thrift/Thrift.h> -#include <boost/shared_ptr.hpp> +#include <thrift/stdcxx.h> #include <thrift/transport/TTransportException.h> #include <string> @@ -260,7 +260,7 @@ public: /** * Default implementation does nothing, just returns the transport given. */ - virtual boost::shared_ptr<TTransport> getTransport(boost::shared_ptr<TTransport> trans) { + virtual stdcxx::shared_ptr<TTransport> getTransport(stdcxx::shared_ptr<TTransport> trans) { return trans; } }; diff --git a/lib/cpp/src/thrift/transport/TTransportUtils.cpp b/lib/cpp/src/thrift/transport/TTransportUtils.cpp index 0f24c95be..869b1fa6b 100644 --- a/lib/cpp/src/thrift/transport/TTransportUtils.cpp +++ b/lib/cpp/src/thrift/transport/TTransportUtils.cpp @@ -94,8 +94,8 @@ void TPipedTransport::flush() { } TPipedFileReaderTransport::TPipedFileReaderTransport( - boost::shared_ptr<TFileReaderTransport> srcTrans, - boost::shared_ptr<TTransport> dstTrans) + stdcxx::shared_ptr<TFileReaderTransport> srcTrans, + stdcxx::shared_ptr<TTransport> dstTrans) : TPipedTransport(srcTrans, dstTrans), srcTrans_(srcTrans) { } diff --git a/lib/cpp/src/thrift/transport/TTransportUtils.h b/lib/cpp/src/thrift/transport/TTransportUtils.h index c22183650..4e8ce267e 100644 --- a/lib/cpp/src/thrift/transport/TTransportUtils.h +++ b/lib/cpp/src/thrift/transport/TTransportUtils.h @@ -63,7 +63,7 @@ public: */ class TPipedTransport : virtual public TTransport { public: - TPipedTransport(boost::shared_ptr<TTransport> srcTrans, boost::shared_ptr<TTransport> dstTrans) + TPipedTransport(stdcxx::shared_ptr<TTransport> srcTrans, stdcxx::shared_ptr<TTransport> dstTrans) : srcTrans_(srcTrans), dstTrans_(dstTrans), rBufSize_(512), @@ -86,8 +86,8 @@ public: } } - TPipedTransport(boost::shared_ptr<TTransport> srcTrans, - boost::shared_ptr<TTransport> dstTrans, + TPipedTransport(stdcxx::shared_ptr<TTransport> srcTrans, + stdcxx::shared_ptr<TTransport> dstTrans, uint32_t sz) : srcTrans_(srcTrans), dstTrans_(dstTrans), @@ -170,7 +170,7 @@ public: void flush(); - boost::shared_ptr<TTransport> getTargetTransport() { return dstTrans_; } + stdcxx::shared_ptr<TTransport> getTargetTransport() { return dstTrans_; } /* * Override TTransport *_virt() functions to invoke our implementations. @@ -181,8 +181,8 @@ public: virtual void write_virt(const uint8_t* buf, uint32_t len) { this->write(buf, len); } protected: - boost::shared_ptr<TTransport> srcTrans_; - boost::shared_ptr<TTransport> dstTrans_; + stdcxx::shared_ptr<TTransport> srcTrans_; + stdcxx::shared_ptr<TTransport> dstTrans_; uint8_t* rBuf_; uint32_t rBufSize_; @@ -204,7 +204,7 @@ protected: class TPipedTransportFactory : public TTransportFactory { public: TPipedTransportFactory() {} - TPipedTransportFactory(boost::shared_ptr<TTransport> dstTrans) { + TPipedTransportFactory(stdcxx::shared_ptr<TTransport> dstTrans) { initializeTargetTransport(dstTrans); } virtual ~TPipedTransportFactory() {} @@ -212,11 +212,11 @@ public: /** * Wraps the base transport into a piped transport. */ - virtual boost::shared_ptr<TTransport> getTransport(boost::shared_ptr<TTransport> srcTrans) { - return boost::shared_ptr<TTransport>(new TPipedTransport(srcTrans, dstTrans_)); + virtual stdcxx::shared_ptr<TTransport> getTransport(stdcxx::shared_ptr<TTransport> srcTrans) { + return stdcxx::shared_ptr<TTransport>(new TPipedTransport(srcTrans, dstTrans_)); } - virtual void initializeTargetTransport(boost::shared_ptr<TTransport> dstTrans) { + virtual void initializeTargetTransport(stdcxx::shared_ptr<TTransport> dstTrans) { if (dstTrans_.get() == NULL) { dstTrans_ = dstTrans; } else { @@ -225,7 +225,7 @@ public: } protected: - boost::shared_ptr<TTransport> dstTrans_; + stdcxx::shared_ptr<TTransport> dstTrans_; }; /** @@ -236,8 +236,8 @@ protected: */ class TPipedFileReaderTransport : public TPipedTransport, public TFileReaderTransport { public: - TPipedFileReaderTransport(boost::shared_ptr<TFileReaderTransport> srcTrans, - boost::shared_ptr<TTransport> dstTrans); + TPipedFileReaderTransport(stdcxx::shared_ptr<TFileReaderTransport> srcTrans, + stdcxx::shared_ptr<TTransport> dstTrans); ~TPipedFileReaderTransport(); @@ -273,7 +273,7 @@ public: protected: // shouldn't be used TPipedFileReaderTransport(); - boost::shared_ptr<TFileReaderTransport> srcTrans_; + stdcxx::shared_ptr<TFileReaderTransport> srcTrans_; }; /** @@ -283,23 +283,23 @@ protected: class TPipedFileReaderTransportFactory : public TPipedTransportFactory { public: TPipedFileReaderTransportFactory() {} - TPipedFileReaderTransportFactory(boost::shared_ptr<TTransport> dstTrans) + TPipedFileReaderTransportFactory(stdcxx::shared_ptr<TTransport> dstTrans) : TPipedTransportFactory(dstTrans) {} virtual ~TPipedFileReaderTransportFactory() {} - boost::shared_ptr<TTransport> getTransport(boost::shared_ptr<TTransport> srcTrans) { - boost::shared_ptr<TFileReaderTransport> pFileReaderTransport - = boost::dynamic_pointer_cast<TFileReaderTransport>(srcTrans); + stdcxx::shared_ptr<TTransport> getTransport(stdcxx::shared_ptr<TTransport> srcTrans) { + stdcxx::shared_ptr<TFileReaderTransport> pFileReaderTransport + = stdcxx::dynamic_pointer_cast<TFileReaderTransport>(srcTrans); if (pFileReaderTransport.get() != NULL) { return getFileReaderTransport(pFileReaderTransport); } else { - return boost::shared_ptr<TTransport>(); + return stdcxx::shared_ptr<TTransport>(); } } - boost::shared_ptr<TFileReaderTransport> getFileReaderTransport( - boost::shared_ptr<TFileReaderTransport> srcTrans) { - return boost::shared_ptr<TFileReaderTransport>( + stdcxx::shared_ptr<TFileReaderTransport> getFileReaderTransport( + stdcxx::shared_ptr<TFileReaderTransport> srcTrans) { + return stdcxx::shared_ptr<TFileReaderTransport>( new TPipedFileReaderTransport(srcTrans, dstTrans_)); } }; diff --git a/lib/cpp/src/thrift/transport/TZlibTransport.h b/lib/cpp/src/thrift/transport/TZlibTransport.h index 18ca588fd..4803c614c 100644 --- a/lib/cpp/src/thrift/transport/TZlibTransport.h +++ b/lib/cpp/src/thrift/transport/TZlibTransport.h @@ -78,7 +78,7 @@ public: * @param cwbuf_size Compressed buffer size for writing. * @param comp_level Compression level (0=none[fast], 6=default, 9=max[slow]). */ - TZlibTransport(boost::shared_ptr<TTransport> transport, + TZlibTransport(stdcxx::shared_ptr<TTransport> transport, int urbuf_size = DEFAULT_URBUF_SIZE, int crbuf_size = DEFAULT_CRBUF_SIZE, int uwbuf_size = DEFAULT_UWBUF_SIZE, @@ -193,7 +193,7 @@ protected: // Larger (or equal) writes are dumped straight to zlib. static const uint32_t MIN_DIRECT_DEFLATE_SIZE = 32; - boost::shared_ptr<TTransport> transport_; + stdcxx::shared_ptr<TTransport> transport_; int urpos_; int uwpos_; @@ -229,8 +229,8 @@ public: virtual ~TZlibTransportFactory() {} - virtual boost::shared_ptr<TTransport> getTransport(boost::shared_ptr<TTransport> trans) { - return boost::shared_ptr<TTransport>(new TZlibTransport(trans)); + virtual stdcxx::shared_ptr<TTransport> getTransport(stdcxx::shared_ptr<TTransport> trans) { + return stdcxx::shared_ptr<TTransport>(new TZlibTransport(trans)); } }; } diff --git a/lib/cpp/src/thrift/windows/TWinsockSingleton.h b/lib/cpp/src/thrift/windows/TWinsockSingleton.h index dc1b52f88..0eab6d4ec 100644 --- a/lib/cpp/src/thrift/windows/TWinsockSingleton.h +++ b/lib/cpp/src/thrift/windows/TWinsockSingleton.h @@ -32,7 +32,6 @@ // boost #include <boost/noncopyable.hpp> -#include <boost/scoped_ptr.hpp> #if USE_BOOST_THREAD #include <boost/thread/once.hpp> @@ -42,6 +41,8 @@ #error For windows you must choose USE_BOOST_THREAD or USE_STD_THREAD #endif +#include <thrift/stdcxx.h> + namespace apache { namespace thrift { namespace transport { @@ -53,7 +54,7 @@ namespace transport { class TWinsockSingleton : private boost::noncopyable { public: - typedef boost::scoped_ptr<TWinsockSingleton> instance_ptr; + typedef stdcxx::shared_ptr<TWinsockSingleton> instance_ptr; private: TWinsockSingleton(void); diff --git a/lib/cpp/test/AllProtocolTests.tcc b/lib/cpp/test/AllProtocolTests.tcc index 3e0b833a9..b6df6563a 100644 --- a/lib/cpp/test/AllProtocolTests.tcc +++ b/lib/cpp/test/AllProtocolTests.tcc @@ -28,7 +28,7 @@ #include "GenericHelpers.h" -using boost::shared_ptr; +using apache::thrift::stdcxx::shared_ptr; using namespace apache::thrift; using namespace apache::thrift::protocol; using namespace apache::thrift::transport; diff --git a/lib/cpp/test/Benchmark.cpp b/lib/cpp/test/Benchmark.cpp index 69e6414a8..afde7d402 100644 --- a/lib/cpp/test/Benchmark.cpp +++ b/lib/cpp/test/Benchmark.cpp @@ -23,8 +23,9 @@ #include <iostream> #define _USE_MATH_DEFINES #include <math.h> -#include "thrift/transport/TBufferTransports.h" #include "thrift/protocol/TBinaryProtocol.h" +#include "thrift/stdcxx.h" +#include "thrift/transport/TBufferTransports.h" #include "gen-cpp/DebugProtoTest_types.h" #ifdef HAVE_SYS_TIME_H @@ -48,11 +49,11 @@ public: }; int main() { - using namespace std; using namespace thrift::test::debug; using namespace apache::thrift::transport; using namespace apache::thrift::protocol; - using namespace boost; + using std::cout; + using std::endl; OneOfEach ooe; ooe.im_true = true; @@ -67,7 +68,7 @@ int main() { ooe.base64 = "\1\2\3\255"; int num = 100000; - boost::shared_ptr<TMemoryBuffer> buf(new TMemoryBuffer(num*1000)); + apache::thrift::stdcxx::shared_ptr<TMemoryBuffer> buf(new TMemoryBuffer(num*1000)); uint8_t* data = NULL; uint32_t datasize = 0; @@ -88,7 +89,7 @@ int main() { buf->getBuffer(&data, &datasize); { - boost::shared_ptr<TMemoryBuffer> buf2(new TMemoryBuffer(data, datasize)); + apache::thrift::stdcxx::shared_ptr<TMemoryBuffer> buf2(new TMemoryBuffer(data, datasize)); TBinaryProtocolT<TMemoryBuffer> prot(buf2); OneOfEach ooe2; double elapsed = 0.0; @@ -116,7 +117,7 @@ int main() { { OneOfEach ooe2; - boost::shared_ptr<TMemoryBuffer> buf2(new TMemoryBuffer(data, datasize)); + apache::thrift::stdcxx::shared_ptr<TMemoryBuffer> buf2(new TMemoryBuffer(data, datasize)); TBinaryProtocolT<TMemoryBuffer, TNetworkLittleEndian> prot(buf2); double elapsed = 0.0; Timer timer; @@ -142,7 +143,7 @@ int main() { } { - boost::shared_ptr<TMemoryBuffer> buf2(new TMemoryBuffer(data, datasize)); + apache::thrift::stdcxx::shared_ptr<TMemoryBuffer> buf2(new TMemoryBuffer(data, datasize)); TBinaryProtocolT<TMemoryBuffer> prot(buf2); OneOfEach ooe2; double elapsed = 0.0; @@ -181,7 +182,7 @@ int main() { buf->getBuffer(&data, &datasize); { - boost::shared_ptr<TMemoryBuffer> buf2(new TMemoryBuffer(data, datasize)); + apache::thrift::stdcxx::shared_ptr<TMemoryBuffer> buf2(new TMemoryBuffer(data, datasize)); TBinaryProtocolT<TMemoryBuffer> prot(buf2); ListDoublePerf listDoublePerf2; double elapsed = 0.0; @@ -205,7 +206,7 @@ int main() { { ListDoublePerf listDoublePerf2; - boost::shared_ptr<TMemoryBuffer> buf2(new TMemoryBuffer(data, datasize)); + apache::thrift::stdcxx::shared_ptr<TMemoryBuffer> buf2(new TMemoryBuffer(data, datasize)); TBinaryProtocolT<TMemoryBuffer, TNetworkLittleEndian> prot(buf2); double elapsed = 0.0; Timer timer; @@ -227,7 +228,7 @@ int main() { } { - boost::shared_ptr<TMemoryBuffer> buf2(new TMemoryBuffer(data, datasize)); + apache::thrift::stdcxx::shared_ptr<TMemoryBuffer> buf2(new TMemoryBuffer(data, datasize)); TBinaryProtocolT<TMemoryBuffer> prot(buf2); ListDoublePerf listDoublePerf2; double elapsed = 0.0; diff --git a/lib/cpp/test/CMakeLists.txt b/lib/cpp/test/CMakeLists.txt index 6d4aa5ecd..1a6062d32 100644 --- a/lib/cpp/test/CMakeLists.txt +++ b/lib/cpp/test/CMakeLists.txt @@ -1,4 +1,4 @@ -# +# # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information @@ -298,7 +298,21 @@ target_link_libraries(TNonblockingServerTest LINK_AGAINST_THRIFT_LIBRARY(TNonblockingServerTest thrift) LINK_AGAINST_THRIFT_LIBRARY(TNonblockingServerTest thriftnb) add_test(NAME TNonblockingServerTest COMMAND TNonblockingServerTest) -endif() + +if(OPENSSL_FOUND AND WITH_OPENSSL) + set(TNonblockingSSLServerTest_SOURCES TNonblockingSSLServerTest.cpp) + add_executable(TNonblockingSSLServerTest ${TNonblockingSSLServerTest_SOURCES}) + include_directories(${LIBEVENT_INCLUDE_DIRS}) + target_link_libraries(TNonblockingSSLServerTest + testgencpp_cob + ${LIBEVENT_LIBRARIES} + ${Boost_LIBRARIES} + ) + LINK_AGAINST_THRIFT_LIBRARY(TNonblockingSSLServerTest thrift) + LINK_AGAINST_THRIFT_LIBRARY(TNonblockingSSLServerTest thriftnb) + add_test(NAME TNonblockingSSLServerTest COMMAND TNonblockingSSLServerTest -- "${CMAKE_CURRENT_SOURCE_DIR}/../../../test/keys") +endif(OPENSSL_FOUND AND WITH_OPENSSL) +endif(WITH_LIBEVENT) if(OPENSSL_FOUND AND WITH_OPENSSL) add_executable(OpenSSLManualInitTest OpenSSLManualInitTest.cpp) diff --git a/lib/cpp/test/DebugProtoTest.cpp b/lib/cpp/test/DebugProtoTest.cpp index c070af225..e04600a32 100644 --- a/lib/cpp/test/DebugProtoTest.cpp +++ b/lib/cpp/test/DebugProtoTest.cpp @@ -21,14 +21,14 @@ #include <cmath> #include "gen-cpp/DebugProtoTest_types.h" #include <thrift/protocol/TDebugProtocol.h> -#include <boost/scoped_ptr.hpp> +#include <thrift/stdcxx.h> #define BOOST_TEST_MODULE DebugProtoTest #include <boost/test/unit_test.hpp> using namespace thrift::test::debug; -static boost::scoped_ptr<OneOfEach> ooe; +static ::apache::thrift::stdcxx::shared_ptr<OneOfEach> ooe; void testCaseSetup_1() { ooe.reset(new OneOfEach); @@ -81,7 +81,7 @@ BOOST_AUTO_TEST_CASE(test_debug_proto_1) { "Expected:\n" << expected_result << "\nGotten:\n" << result); } -static boost::scoped_ptr<Nesting> n; +static ::apache::thrift::stdcxx::shared_ptr<Nesting> n; void testCaseSetup_2() { testCaseSetup_1(); @@ -149,7 +149,7 @@ BOOST_AUTO_TEST_CASE(test_debug_proto_2) { "Expected:\n" << expected_result << "\nGotten:\n" << result); } -static boost::scoped_ptr<HolyMoley> hm; +static ::apache::thrift::stdcxx::shared_ptr<HolyMoley> hm; void testCaseSetup_3() { testCaseSetup_2(); diff --git a/lib/cpp/test/GenericHelpers.h b/lib/cpp/test/GenericHelpers.h index c175561c1..e131c42ff 100644 --- a/lib/cpp/test/GenericHelpers.h +++ b/lib/cpp/test/GenericHelpers.h @@ -20,13 +20,10 @@ #ifndef _THRIFT_TEST_GENERICHELPERS_H_ #define _THRIFT_TEST_GENERICHELPERS_H_ 1 -#include <thrift/protocol/TBinaryProtocol.h> -#include <thrift/transport/TBufferTransports.h> +#include <thrift/protocol/TProtocol.h> +#include <thrift/stdcxx.h> #include <thrift/Thrift.h> -using boost::shared_ptr; -using namespace apache::thrift::protocol; - /* ClassName Helper for cleaner exceptions */ class ClassNames { public: @@ -66,43 +63,43 @@ class GenericIO { public: /* Write functions */ - static uint32_t write(shared_ptr<TProtocol> proto, const int8_t& val) { + static uint32_t write(apache::thrift::stdcxx::shared_ptr<apache::thrift::protocol::TProtocol> proto, const int8_t& val) { return proto->writeByte(val); } - static uint32_t write(shared_ptr<TProtocol> proto, const int16_t& val) { + static uint32_t write(apache::thrift::stdcxx::shared_ptr<apache::thrift::protocol::TProtocol> proto, const int16_t& val) { return proto->writeI16(val); } - static uint32_t write(shared_ptr<TProtocol> proto, const int32_t& val) { + static uint32_t write(apache::thrift::stdcxx::shared_ptr<apache::thrift::protocol::TProtocol> proto, const int32_t& val) { return proto->writeI32(val); } - static uint32_t write(shared_ptr<TProtocol> proto, const double& val) { + static uint32_t write(apache::thrift::stdcxx::shared_ptr<apache::thrift::protocol::TProtocol> proto, const double& val) { return proto->writeDouble(val); } - static uint32_t write(shared_ptr<TProtocol> proto, const int64_t& val) { + static uint32_t write(apache::thrift::stdcxx::shared_ptr<apache::thrift::protocol::TProtocol> proto, const int64_t& val) { return proto->writeI64(val); } - static uint32_t write(shared_ptr<TProtocol> proto, const std::string& val) { + static uint32_t write(apache::thrift::stdcxx::shared_ptr<apache::thrift::protocol::TProtocol> proto, const std::string& val) { return proto->writeString(val); } /* Read functions */ - static uint32_t read(shared_ptr<TProtocol> proto, int8_t& val) { return proto->readByte(val); } + static uint32_t read(apache::thrift::stdcxx::shared_ptr<apache::thrift::protocol::TProtocol> proto, int8_t& val) { return proto->readByte(val); } - static uint32_t read(shared_ptr<TProtocol> proto, int16_t& val) { return proto->readI16(val); } + static uint32_t read(apache::thrift::stdcxx::shared_ptr<apache::thrift::protocol::TProtocol> proto, int16_t& val) { return proto->readI16(val); } - static uint32_t read(shared_ptr<TProtocol> proto, int32_t& val) { return proto->readI32(val); } + static uint32_t read(apache::thrift::stdcxx::shared_ptr<apache::thrift::protocol::TProtocol> proto, int32_t& val) { return proto->readI32(val); } - static uint32_t read(shared_ptr<TProtocol> proto, int64_t& val) { return proto->readI64(val); } + static uint32_t read(apache::thrift::stdcxx::shared_ptr<apache::thrift::protocol::TProtocol> proto, int64_t& val) { return proto->readI64(val); } - static uint32_t read(shared_ptr<TProtocol> proto, double& val) { return proto->readDouble(val); } + static uint32_t read(apache::thrift::stdcxx::shared_ptr<apache::thrift::protocol::TProtocol> proto, double& val) { return proto->readDouble(val); } - static uint32_t read(shared_ptr<TProtocol> proto, std::string& val) { + static uint32_t read(apache::thrift::stdcxx::shared_ptr<apache::thrift::protocol::TProtocol> proto, std::string& val) { return proto->readString(val); } }; diff --git a/lib/cpp/test/JSONProtoTest.cpp b/lib/cpp/test/JSONProtoTest.cpp index 2ac7adc6f..77bc2500c 100644 --- a/lib/cpp/test/JSONProtoTest.cpp +++ b/lib/cpp/test/JSONProtoTest.cpp @@ -21,19 +21,20 @@ #include <cmath> #include <iomanip> #include <sstream> -#include <thrift/transport/TBufferTransports.h> #include <thrift/protocol/TJSONProtocol.h> -#include <boost/scoped_ptr.hpp> +#include <thrift/stdcxx.h> +#include <thrift/transport/TBufferTransports.h> #include "gen-cpp/DebugProtoTest_types.h" #define BOOST_TEST_MODULE JSONProtoTest #include <boost/test/unit_test.hpp> using namespace thrift::test::debug; +using namespace apache::thrift; using apache::thrift::transport::TMemoryBuffer; using apache::thrift::protocol::TJSONProtocol; -static boost::scoped_ptr<OneOfEach> ooe; +static stdcxx::shared_ptr<OneOfEach> ooe; void testCaseSetup_1() { ooe.reset(new OneOfEach); @@ -66,7 +67,7 @@ BOOST_AUTO_TEST_CASE(test_json_proto_1) { "Expected:\n" << expected_result << "\nGotten:\n" << result); } -static boost::scoped_ptr<Nesting> n; +static stdcxx::shared_ptr<Nesting> n; void testCaseSetup_2() { testCaseSetup_1(); @@ -106,7 +107,7 @@ BOOST_AUTO_TEST_CASE(test_json_proto_2) { "Expected:\n" << expected_result << "\nGotten:\n" << result); } -static boost::scoped_ptr<HolyMoley> hm; +static stdcxx::shared_ptr<HolyMoley> hm; void testCaseSetup_3() { testCaseSetup_2(); @@ -184,8 +185,8 @@ BOOST_AUTO_TEST_CASE(test_json_proto_3) { BOOST_AUTO_TEST_CASE(test_json_proto_4) { testCaseSetup_1(); - boost::shared_ptr<TMemoryBuffer> buffer(new TMemoryBuffer()); - boost::shared_ptr<TJSONProtocol> proto(new TJSONProtocol(buffer)); + stdcxx::shared_ptr<TMemoryBuffer> buffer(new TMemoryBuffer()); + stdcxx::shared_ptr<TJSONProtocol> proto(new TJSONProtocol(buffer)); ooe->write(proto.get()); OneOfEach ooe2; @@ -197,8 +198,8 @@ BOOST_AUTO_TEST_CASE(test_json_proto_4) { BOOST_AUTO_TEST_CASE(test_json_proto_5) { testCaseSetup_3(); - boost::shared_ptr<TMemoryBuffer> buffer(new TMemoryBuffer()); - boost::shared_ptr<TJSONProtocol> proto(new TJSONProtocol(buffer)); + stdcxx::shared_ptr<TMemoryBuffer> buffer(new TMemoryBuffer()); + stdcxx::shared_ptr<TJSONProtocol> proto(new TJSONProtocol(buffer)); hm->write(proto.get()); HolyMoley hm2; @@ -235,8 +236,8 @@ BOOST_AUTO_TEST_CASE(test_json_proto_6) { } BOOST_AUTO_TEST_CASE(test_json_proto_7) { - boost::shared_ptr<TMemoryBuffer> buffer(new TMemoryBuffer()); - boost::shared_ptr<TJSONProtocol> proto(new TJSONProtocol(buffer)); + stdcxx::shared_ptr<TMemoryBuffer> buffer(new TMemoryBuffer()); + stdcxx::shared_ptr<TJSONProtocol> proto(new TJSONProtocol(buffer)); Base64 base; base.a = 123; @@ -264,9 +265,9 @@ BOOST_AUTO_TEST_CASE(test_json_proto_8) { "\",3,1,2,3]}}"; const std::size_t bufSiz = strlen(json_string) * sizeof(char); - boost::shared_ptr<TMemoryBuffer> buffer(new TMemoryBuffer( + stdcxx::shared_ptr<TMemoryBuffer> buffer(new TMemoryBuffer( (uint8_t*)(json_string), static_cast<uint32_t>(bufSiz))); - boost::shared_ptr<TJSONProtocol> proto(new TJSONProtocol(buffer)); + stdcxx::shared_ptr<TJSONProtocol> proto(new TJSONProtocol(buffer)); OneOfEach ooe2; @@ -293,9 +294,9 @@ BOOST_AUTO_TEST_CASE(test_json_unicode_escaped) { "\",3,1,2,3]}}"; const char* expected_zomg_unicode = "\xe0\xb8\x81 \xf0\x9d\x94\xbe"; - boost::shared_ptr<TMemoryBuffer> buffer(new TMemoryBuffer( + stdcxx::shared_ptr<TMemoryBuffer> buffer(new TMemoryBuffer( (uint8_t*)(json_string), sizeof(json_string))); - boost::shared_ptr<TJSONProtocol> proto(new TJSONProtocol(buffer)); + stdcxx::shared_ptr<TJSONProtocol> proto(new TJSONProtocol(buffer)); OneOfEach ooe2; ooe2.read(proto.get()); @@ -314,9 +315,9 @@ BOOST_AUTO_TEST_CASE(test_json_unicode_escaped_missing_low_surrogate) { ":[\"i8\",3,1,2,3]},\"13\":{\"lst\":[\"i16\",3,1,2,3]},\"14\":{\"lst\":[\"i64" "\",3,1,2,3]}}"; - boost::shared_ptr<TMemoryBuffer> buffer(new TMemoryBuffer( + stdcxx::shared_ptr<TMemoryBuffer> buffer(new TMemoryBuffer( (uint8_t*)(json_string), sizeof(json_string))); - boost::shared_ptr<TJSONProtocol> proto(new TJSONProtocol(buffer)); + stdcxx::shared_ptr<TJSONProtocol> proto(new TJSONProtocol(buffer)); OneOfEach ooe2; BOOST_CHECK_THROW(ooe2.read(proto.get()), @@ -332,9 +333,9 @@ BOOST_AUTO_TEST_CASE(test_json_unicode_escaped_missing_hi_surrogate) { ":[\"i8\",3,1,2,3]},\"13\":{\"lst\":[\"i16\",3,1,2,3]},\"14\":{\"lst\":[\"i64" "\",3,1,2,3]}}"; - boost::shared_ptr<TMemoryBuffer> buffer(new TMemoryBuffer( + stdcxx::shared_ptr<TMemoryBuffer> buffer(new TMemoryBuffer( (uint8_t*)(json_string), sizeof(json_string))); - boost::shared_ptr<TJSONProtocol> proto(new TJSONProtocol(buffer)); + stdcxx::shared_ptr<TJSONProtocol> proto(new TJSONProtocol(buffer)); OneOfEach ooe2; BOOST_CHECK_THROW(ooe2.read(proto.get()), diff --git a/lib/cpp/test/OpenSSLManualInitTest.cpp b/lib/cpp/test/OpenSSLManualInitTest.cpp index 5cd5e48ce..a30b3039a 100644 --- a/lib/cpp/test/OpenSSLManualInitTest.cpp +++ b/lib/cpp/test/OpenSSLManualInitTest.cpp @@ -28,7 +28,6 @@ #include <openssl/evp.h> #include <thrift/transport/TSSLSocket.h> -using namespace std; using namespace apache::thrift::transport; void make_isolated_sslsocketfactory() { diff --git a/lib/cpp/test/OptionalRequiredTest.cpp b/lib/cpp/test/OptionalRequiredTest.cpp index b0e5ef74b..55fe249ec 100644 --- a/lib/cpp/test/OptionalRequiredTest.cpp +++ b/lib/cpp/test/OptionalRequiredTest.cpp @@ -40,7 +40,7 @@ template<typename Struct> void trywrite(const Struct& s, bool should_work) { bool worked; try { - TBinaryProtocol protocol(boost::shared_ptr<TTransport>(new TMemoryBuffer)); + TBinaryProtocol protocol(stdcxx::shared_ptr<TTransport>(new TMemoryBuffer)); s.write(&protocol); worked = true; } catch (TProtocolException & ex) { @@ -52,7 +52,7 @@ void trywrite(const Struct& s, bool should_work) { template <typename Struct1, typename Struct2> void write_to_read(const Struct1& w, Struct2& r) { - TBinaryProtocol protocol(boost::shared_ptr<TTransport>(new TMemoryBuffer)); + TBinaryProtocol protocol(stdcxx::shared_ptr<TTransport>(new TMemoryBuffer)); w.write(&protocol); r.read(&protocol); } @@ -303,7 +303,7 @@ BOOST_AUTO_TEST_CASE(test_optional_required_11) { o1.im_big.push_back(mymap); BOOST_CHECK(o1 == o2); - TBinaryProtocol protocol(boost::shared_ptr<TTransport>(new TMemoryBuffer)); + TBinaryProtocol protocol(stdcxx::shared_ptr<TTransport>(new TMemoryBuffer)); o1.write(&protocol); o1.im_big.push_back(mymap); diff --git a/lib/cpp/test/RecursiveTest.cpp b/lib/cpp/test/RecursiveTest.cpp index e3e3f507b..ce5569bf7 100644 --- a/lib/cpp/test/RecursiveTest.cpp +++ b/lib/cpp/test/RecursiveTest.cpp @@ -22,20 +22,21 @@ */ #include "gen-cpp/Recursive_types.h" -#include <thrift/transport/TBufferTransports.h> #include <thrift/protocol/TBinaryProtocol.h> +#include <thrift/stdcxx.h> +#include <thrift/transport/TBufferTransports.h> #define BOOST_TEST_MODULE RecursiveTest #include <boost/test/unit_test.hpp> using apache::thrift::transport::TMemoryBuffer; using apache::thrift::protocol::TBinaryProtocol; -using boost::shared_ptr; +using apache::thrift::stdcxx::shared_ptr; BOOST_AUTO_TEST_CASE(test_recursive_1) { shared_ptr<TMemoryBuffer> buf(new TMemoryBuffer()); shared_ptr<TBinaryProtocol> prot(new TBinaryProtocol(buf)); - + RecTree tree; RecTree child; tree.children.push_back(child); @@ -50,9 +51,9 @@ BOOST_AUTO_TEST_CASE(test_recursive_1) { BOOST_AUTO_TEST_CASE(test_recursive_2) { shared_ptr<TMemoryBuffer> buf(new TMemoryBuffer()); shared_ptr<TBinaryProtocol> prot(new TBinaryProtocol(buf)); - + RecList l; - boost::shared_ptr<RecList> l2(new RecList); + shared_ptr<RecList> l2(new RecList); l.nextitem = l2; l.write(prot.get()); @@ -68,7 +69,7 @@ BOOST_AUTO_TEST_CASE(test_recursive_3) { shared_ptr<TBinaryProtocol> prot(new TBinaryProtocol(buf)); CoRec c; - boost::shared_ptr<CoRec2> r(new CoRec2); + shared_ptr<CoRec2> r(new CoRec2); c.other = r; c.write(prot.get()); @@ -82,7 +83,7 @@ BOOST_AUTO_TEST_CASE(test_recursive_4) { shared_ptr<TMemoryBuffer> buf(new TMemoryBuffer()); shared_ptr<TBinaryProtocol> prot(new TBinaryProtocol(buf)); - boost::shared_ptr<RecList> depthLimit(new RecList); + shared_ptr<RecList> depthLimit(new RecList); depthLimit->nextitem = depthLimit; BOOST_CHECK_THROW(depthLimit->write(prot.get()), apache::thrift::protocol::TProtocolException); diff --git a/lib/cpp/test/SecurityTest.cpp b/lib/cpp/test/SecurityTest.cpp index 23650d628..6eb1fe342 100644 --- a/lib/cpp/test/SecurityTest.cpp +++ b/lib/cpp/test/SecurityTest.cpp @@ -19,13 +19,11 @@ #define BOOST_TEST_MODULE SecurityTest #include <boost/test/unit_test.hpp> -#include <boost/bind.hpp> #include <boost/filesystem.hpp> #include <boost/foreach.hpp> #include <boost/format.hpp> -#include <boost/make_shared.hpp> -#include <boost/shared_ptr.hpp> #include <boost/thread.hpp> +#include <thrift/stdcxx.h> #include <thrift/transport/TSSLServerSocket.h> #include <thrift/transport/TSSLSocket.h> #include <thrift/transport/TTransport.h> @@ -42,6 +40,9 @@ using apache::thrift::transport::TTransport; using apache::thrift::transport::TTransportException; using apache::thrift::transport::TTransportFactory; +using apache::thrift::stdcxx::bind; +using apache::thrift::stdcxx::shared_ptr; + boost::filesystem::path keyDir; boost::filesystem::path certFile(const std::string& filename) { @@ -54,36 +55,36 @@ struct GlobalFixture GlobalFixture() { using namespace boost::unit_test::framework; - for (int i = 0; i < master_test_suite().argc; ++i) - { - BOOST_TEST_MESSAGE(boost::format("argv[%1%] = \"%2%\"") % i % master_test_suite().argv[i]); - } + for (int i = 0; i < master_test_suite().argc; ++i) + { + BOOST_TEST_MESSAGE(boost::format("argv[%1%] = \"%2%\"") % i % master_test_suite().argv[i]); + } #ifdef __linux__ - // OpenSSL calls send() without MSG_NOSIGPIPE so writing to a socket that has - // disconnected can cause a SIGPIPE signal... - signal(SIGPIPE, SIG_IGN); + // OpenSSL calls send() without MSG_NOSIGPIPE so writing to a socket that has + // disconnected can cause a SIGPIPE signal... + signal(SIGPIPE, SIG_IGN); #endif - TSSLSocketFactory::setManualOpenSSLInitialization(true); - apache::thrift::transport::initializeOpenSSL(); - - keyDir = boost::filesystem::current_path().parent_path().parent_path().parent_path() / "test" / "keys"; - if (!boost::filesystem::exists(certFile("server.crt"))) - { - keyDir = boost::filesystem::path(master_test_suite().argv[master_test_suite().argc - 1]); - if (!boost::filesystem::exists(certFile("server.crt"))) - { - throw std::invalid_argument("The last argument to this test must be the directory containing the test certificate(s)."); - } - } + TSSLSocketFactory::setManualOpenSSLInitialization(true); + apache::thrift::transport::initializeOpenSSL(); + + keyDir = boost::filesystem::current_path().parent_path().parent_path().parent_path() / "test" / "keys"; + if (!boost::filesystem::exists(certFile("server.crt"))) + { + keyDir = boost::filesystem::path(master_test_suite().argv[master_test_suite().argc - 1]); + if (!boost::filesystem::exists(certFile("server.crt"))) + { + throw std::invalid_argument("The last argument to this test must be the directory containing the test certificate(s)."); + } + } } virtual ~GlobalFixture() { - apache::thrift::transport::cleanupOpenSSL(); + apache::thrift::transport::cleanupOpenSSL(); #ifdef __linux__ - signal(SIGPIPE, SIG_DFL); + signal(SIGPIPE, SIG_DFL); #endif } }; @@ -102,8 +103,8 @@ struct SecurityFixture { boost::mutex::scoped_lock lock(mMutex); - boost::shared_ptr<TSSLSocketFactory> pServerSocketFactory; - boost::shared_ptr<TSSLServerSocket> pServerSocket; + shared_ptr<TSSLSocketFactory> pServerSocketFactory; + shared_ptr<TSSLServerSocket> pServerSocket; pServerSocketFactory.reset(new TSSLSocketFactory(static_cast<apache::thrift::transport::SSLProtocol>(protocol))); pServerSocketFactory->ciphers("ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH"); @@ -111,7 +112,7 @@ struct SecurityFixture pServerSocketFactory->loadPrivateKey(certFile("server.key").string().c_str()); pServerSocketFactory->server(true); pServerSocket.reset(new TSSLServerSocket("localhost", 0, pServerSocketFactory)); - boost::shared_ptr<TTransport> connectedClient; + shared_ptr<TTransport> connectedClient; try { @@ -153,8 +154,8 @@ struct SecurityFixture { try { - boost::shared_ptr<TSSLSocketFactory> pClientSocketFactory; - boost::shared_ptr<TSSLSocket> pClientSocket; + shared_ptr<TSSLSocketFactory> pClientSocketFactory; + shared_ptr<TSSLSocket> pClientSocket; try { @@ -255,10 +256,10 @@ BOOST_AUTO_TEST_CASE(ssl_security_matrix) mConnected = false; boost::thread_group threads; - threads.create_thread(boost::bind(&SecurityFixture::server, this, static_cast<apache::thrift::transport::SSLProtocol>(si))); + threads.create_thread(bind(&SecurityFixture::server, this, static_cast<apache::thrift::transport::SSLProtocol>(si))); mCVar.wait(lock); // wait for listen() to succeed lock.unlock(); - threads.create_thread(boost::bind(&SecurityFixture::client, this, static_cast<apache::thrift::transport::SSLProtocol>(ci))); + threads.create_thread(bind(&SecurityFixture::client, this, static_cast<apache::thrift::transport::SSLProtocol>(ci))); threads.join_all(); BOOST_CHECK_MESSAGE(mConnected == matrix[ci][si], diff --git a/lib/cpp/test/SpecializationTest.cpp b/lib/cpp/test/SpecializationTest.cpp index e851bac8c..a060b4fcb 100644 --- a/lib/cpp/test/SpecializationTest.cpp +++ b/lib/cpp/test/SpecializationTest.cpp @@ -82,8 +82,8 @@ BOOST_AUTO_TEST_CASE(test_specialization_1) { stage2.back().message = "nevermore"; hm.bonks["poe"] = stage2; - boost::shared_ptr<TMemoryBuffer> buffer(new TMemoryBuffer()); - boost::shared_ptr<TProtocol> proto(new MyProtocol(buffer)); + apache::thrift::stdcxx::shared_ptr<TMemoryBuffer> buffer(new TMemoryBuffer()); + apache::thrift::stdcxx::shared_ptr<TProtocol> proto(new MyProtocol(buffer)); ooe.write(proto.get()); OneOfEach ooe2; diff --git a/lib/cpp/test/TBufferBaseTest.cpp b/lib/cpp/test/TBufferBaseTest.cpp index 5d0bf456c..4e3509ede 100644 --- a/lib/cpp/test/TBufferBaseTest.cpp +++ b/lib/cpp/test/TBufferBaseTest.cpp @@ -21,13 +21,14 @@ #include <boost/test/auto_unit_test.hpp> #include <thrift/transport/TBufferTransports.h> #include <thrift/transport/TShortReadTransport.h> +#include <thrift/stdcxx.h> -using std::string; -using boost::shared_ptr; +using apache::thrift::stdcxx::shared_ptr; using apache::thrift::transport::TMemoryBuffer; using apache::thrift::transport::TBufferedTransport; using apache::thrift::transport::TFramedTransport; using apache::thrift::transport::test::TShortReadTransport; +using std::string; // Shamelessly copied from ZlibTransport. TODO: refactor. unsigned int dist[][5000] = { diff --git a/lib/cpp/test/TMemoryBufferTest.cpp b/lib/cpp/test/TMemoryBufferTest.cpp index 84103e3f6..1586609bf 100644 --- a/lib/cpp/test/TMemoryBufferTest.cpp +++ b/lib/cpp/test/TMemoryBufferTest.cpp @@ -21,8 +21,9 @@ #include <iostream> #include <climits> #include <vector> -#include <thrift/transport/TBufferTransports.h> #include <thrift/protocol/TBinaryProtocol.h> +#include <thrift/stdcxx.h> +#include <thrift/transport/TBufferTransports.h> #include "gen-cpp/ThriftTest_types.h" BOOST_AUTO_TEST_SUITE(TMemoryBufferTest) @@ -30,7 +31,7 @@ BOOST_AUTO_TEST_SUITE(TMemoryBufferTest) using apache::thrift::protocol::TBinaryProtocol; using apache::thrift::transport::TMemoryBuffer; using apache::thrift::transport::TTransportException; -using boost::shared_ptr; +using apache::thrift::stdcxx::shared_ptr; using std::cout; using std::endl; using std::string; diff --git a/lib/cpp/test/TNonblockingSSLServerTest.cpp b/lib/cpp/test/TNonblockingSSLServerTest.cpp index f21dd18a7..3e9700f1f 100644 --- a/lib/cpp/test/TNonblockingSSLServerTest.cpp +++ b/lib/cpp/test/TNonblockingSSLServerTest.cpp @@ -105,8 +105,8 @@ BOOST_GLOBAL_FIXTURE(GlobalFixtureSSL); BOOST_GLOBAL_FIXTURE(GlobalFixtureSSL) #endif -boost::shared_ptr<TSSLSocketFactory> createServerSocketFactory() { - boost::shared_ptr<TSSLSocketFactory> pServerSocketFactory; +stdcxx::shared_ptr<TSSLSocketFactory> createServerSocketFactory() { + stdcxx::shared_ptr<TSSLSocketFactory> pServerSocketFactory; pServerSocketFactory.reset(new TSSLSocketFactory()); pServerSocketFactory->ciphers("ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH"); @@ -116,8 +116,8 @@ boost::shared_ptr<TSSLSocketFactory> createServerSocketFactory() { return pServerSocketFactory; } -boost::shared_ptr<TSSLSocketFactory> createClientSocketFactory() { - boost::shared_ptr<TSSLSocketFactory> pClientSocketFactory; +stdcxx::shared_ptr<TSSLSocketFactory> createClientSocketFactory() { + stdcxx::shared_ptr<TSSLSocketFactory> pClientSocketFactory; pClientSocketFactory.reset(new TSSLSocketFactory()); pClientSocketFactory->authenticate(true); @@ -145,12 +145,12 @@ private: struct Runner : public apache::thrift::concurrency::Runnable { int port; - boost::shared_ptr<event_base> userEventBase; - boost::shared_ptr<TProcessor> processor; - boost::shared_ptr<server::TNonblockingServer> server; - boost::shared_ptr<ListenEventHandler> listenHandler; - boost::shared_ptr<TSSLSocketFactory> pServerSocketFactory; - boost::shared_ptr<transport::TNonblockingSSLServerSocket> socket; + stdcxx::shared_ptr<event_base> userEventBase; + stdcxx::shared_ptr<TProcessor> processor; + stdcxx::shared_ptr<server::TNonblockingServer> server; + stdcxx::shared_ptr<ListenEventHandler> listenHandler; + stdcxx::shared_ptr<TSSLSocketFactory> pServerSocketFactory; + stdcxx::shared_ptr<transport::TNonblockingSSLServerSocket> socket; Mutex mutex_; Runner() { @@ -198,7 +198,7 @@ private: }; protected: - Fixture() : processor(new test::ParentServiceProcessor(boost::make_shared<Handler>())) {} + Fixture() : processor(new test::ParentServiceProcessor(stdcxx::make_shared<Handler>())) {} ~Fixture() { if (server) { @@ -214,12 +214,12 @@ protected: } int startServer(int port) { - boost::shared_ptr<Runner> runner(new Runner); + stdcxx::shared_ptr<Runner> runner(new Runner); runner->port = port; runner->processor = processor; runner->userEventBase = userEventBase_; - boost::scoped_ptr<apache::thrift::concurrency::ThreadFactory> threadFactory( + apache::thrift::stdcxx::scoped_ptr<apache::thrift::concurrency::ThreadFactory> threadFactory( new apache::thrift::concurrency::PlatformThreadFactory( #if !USE_BOOST_THREAD && !USE_STD_THREAD concurrency::PlatformThreadFactory::OTHER, concurrency::PlatformThreadFactory::NORMAL, @@ -235,11 +235,11 @@ protected: } bool canCommunicate(int serverPort) { - boost::shared_ptr<TSSLSocketFactory> pClientSocketFactory = createClientSocketFactory(); - boost::shared_ptr<TSSLSocket> socket = pClientSocketFactory->createSocket("localhost", serverPort); + stdcxx::shared_ptr<TSSLSocketFactory> pClientSocketFactory = createClientSocketFactory(); + stdcxx::shared_ptr<TSSLSocket> socket = pClientSocketFactory->createSocket("localhost", serverPort); socket->open(); - test::ParentServiceClient client(boost::make_shared<protocol::TBinaryProtocol>( - boost::make_shared<transport::TFramedTransport>(socket))); + test::ParentServiceClient client(stdcxx::make_shared<protocol::TBinaryProtocol>( + stdcxx::make_shared<transport::TFramedTransport>(socket))); client.addString("foo"); std::vector<std::string> strings; client.getStrings(strings); @@ -247,12 +247,12 @@ protected: } private: - boost::shared_ptr<event_base> userEventBase_; - boost::shared_ptr<test::ParentServiceProcessor> processor; + stdcxx::shared_ptr<event_base> userEventBase_; + stdcxx::shared_ptr<test::ParentServiceProcessor> processor; protected: - boost::shared_ptr<server::TNonblockingServer> server; + stdcxx::shared_ptr<server::TNonblockingServer> server; private: - boost::shared_ptr<apache::thrift::concurrency::Thread> thread; + stdcxx::shared_ptr<apache::thrift::concurrency::Thread> thread; }; diff --git a/lib/cpp/test/TNonblockingServerTest.cpp b/lib/cpp/test/TNonblockingServerTest.cpp index 36c64b173..74ffd1d54 100644 --- a/lib/cpp/test/TNonblockingServerTest.cpp +++ b/lib/cpp/test/TNonblockingServerTest.cpp @@ -19,22 +19,29 @@ #define BOOST_TEST_MODULE TNonblockingServerTest #include <boost/test/unit_test.hpp> -#include <boost/smart_ptr.hpp> #include "thrift/concurrency/Monitor.h" #include "thrift/concurrency/Thread.h" #include "thrift/server/TNonblockingServer.h" #include "thrift/transport/TNonblockingServerSocket.h" +#include "thrift/stdcxx.h" #include "gen-cpp/ParentService.h" #include <event.h> -using namespace apache::thrift; using apache::thrift::concurrency::Guard; using apache::thrift::concurrency::Monitor; using apache::thrift::concurrency::Mutex; +using apache::thrift::concurrency::PlatformThreadFactory; +using apache::thrift::concurrency::Runnable; +using apache::thrift::concurrency::Thread; +using apache::thrift::concurrency::ThreadFactory; using apache::thrift::server::TServerEventHandler; +using apache::thrift::stdcxx::make_shared; +using apache::thrift::stdcxx::shared_ptr; + +using namespace apache::thrift; struct Handler : public test::ParentServiceIf { void addString(const std::string& s) { strings_.push_back(s); } @@ -66,13 +73,13 @@ private: bool ready_; }; - struct Runner : public apache::thrift::concurrency::Runnable { + struct Runner : public Runnable { int port; - boost::shared_ptr<event_base> userEventBase; - boost::shared_ptr<TProcessor> processor; - boost::shared_ptr<server::TNonblockingServer> server; - boost::shared_ptr<ListenEventHandler> listenHandler; - boost::shared_ptr<transport::TNonblockingServerSocket> socket; + shared_ptr<event_base> userEventBase; + shared_ptr<TProcessor> processor; + shared_ptr<server::TNonblockingServer> server; + shared_ptr<ListenEventHandler> listenHandler; + shared_ptr<transport::TNonblockingServerSocket> socket; Mutex mutex_; Runner() { @@ -118,7 +125,7 @@ private: }; protected: - Fixture() : processor(new test::ParentServiceProcessor(boost::make_shared<Handler>())) {} + Fixture() : processor(new test::ParentServiceProcessor(make_shared<Handler>())) {} ~Fixture() { if (server) { @@ -134,15 +141,15 @@ protected: } int startServer(int port) { - boost::shared_ptr<Runner> runner(new Runner); + shared_ptr<Runner> runner(new Runner); runner->port = port; runner->processor = processor; runner->userEventBase = userEventBase_; - boost::scoped_ptr<apache::thrift::concurrency::ThreadFactory> threadFactory( - new apache::thrift::concurrency::PlatformThreadFactory( + shared_ptr<ThreadFactory> threadFactory( + new PlatformThreadFactory( #if !USE_BOOST_THREAD && !USE_STD_THREAD - concurrency::PlatformThreadFactory::OTHER, concurrency::PlatformThreadFactory::NORMAL, + PlatformThreadFactory::OTHER, PlatformThreadFactory::NORMAL, 1, #endif false)); @@ -155,10 +162,10 @@ protected: } bool canCommunicate(int serverPort) { - boost::shared_ptr<transport::TSocket> socket(new transport::TSocket("localhost", serverPort)); + shared_ptr<transport::TSocket> socket(new transport::TSocket("localhost", serverPort)); socket->open(); - test::ParentServiceClient client(boost::make_shared<protocol::TBinaryProtocol>( - boost::make_shared<transport::TFramedTransport>(socket))); + test::ParentServiceClient client(make_shared<protocol::TBinaryProtocol>( + make_shared<transport::TFramedTransport>(socket))); client.addString("foo"); std::vector<std::string> strings; client.getStrings(strings); @@ -166,12 +173,12 @@ protected: } private: - boost::shared_ptr<event_base> userEventBase_; - boost::shared_ptr<test::ParentServiceProcessor> processor; + shared_ptr<event_base> userEventBase_; + shared_ptr<test::ParentServiceProcessor> processor; protected: - boost::shared_ptr<server::TNonblockingServer> server; + shared_ptr<server::TNonblockingServer> server; private: - boost::shared_ptr<apache::thrift::concurrency::Thread> thread; + shared_ptr<concurrency::Thread> thread; }; diff --git a/lib/cpp/test/TPipeInterruptTest.cpp b/lib/cpp/test/TPipeInterruptTest.cpp index 80e4c1fea..232e4bb73 100644 --- a/lib/cpp/test/TPipeInterruptTest.cpp +++ b/lib/cpp/test/TPipeInterruptTest.cpp @@ -22,17 +22,18 @@ #include <boost/test/test_tools.hpp> #include <boost/test/unit_test_suite.hpp> -#include <boost/bind.hpp> #include <boost/chrono/duration.hpp> #include <boost/date_time/posix_time/posix_time_duration.hpp> #include <boost/thread/thread.hpp> #include <thrift/transport/TPipe.h> #include <thrift/transport/TPipeServer.h> +#include <thrift/stdcxx.h> using apache::thrift::transport::TPipeServer; using apache::thrift::transport::TPipe; using apache::thrift::transport::TTransport; using apache::thrift::transport::TTransportException; +using namespace apache::thrift; BOOST_AUTO_TEST_SUITE(TPipeInterruptTest) @@ -51,7 +52,7 @@ static void acceptWorker(TPipeServer *pipe) { { for (;;) { - boost::shared_ptr<TTransport> temp = pipe->accept(); + stdcxx::shared_ptr<TTransport> temp = pipe->accept(); } } catch (...) {/*just want to make sure nothing crashes*/ } @@ -69,8 +70,8 @@ BOOST_AUTO_TEST_CASE(stress_pipe_accept_interruption) { { TPipeServer pipeServer("TPipeInterruptTest"); pipeServer.listen(); - boost::thread acceptThread(boost::bind(acceptWorker, &pipeServer)); - boost::thread interruptThread(boost::bind(interruptWorker, &pipeServer)); + boost::thread acceptThread(stdcxx::bind(acceptWorker, &pipeServer)); + boost::thread interruptThread(stdcxx::bind(interruptWorker, &pipeServer)); try { for (;;) diff --git a/lib/cpp/test/TPipedTransportTest.cpp b/lib/cpp/test/TPipedTransportTest.cpp index 3221fb940..a3ce662a3 100644 --- a/lib/cpp/test/TPipedTransportTest.cpp +++ b/lib/cpp/test/TPipedTransportTest.cpp @@ -18,6 +18,7 @@ */ #include <thrift/Thrift.h> +#include <thrift/stdcxx.h> #include <thrift/transport/TTransportUtils.h> #include <thrift/transport/TBufferTransports.h> @@ -27,11 +28,12 @@ using apache::thrift::transport::TTransportException; using apache::thrift::transport::TPipedTransport; using apache::thrift::transport::TMemoryBuffer; +using namespace apache::thrift; BOOST_AUTO_TEST_CASE(test_read_write) { - boost::shared_ptr<TMemoryBuffer> underlying(new TMemoryBuffer); - boost::shared_ptr<TMemoryBuffer> pipe(new TMemoryBuffer); - boost::shared_ptr<TPipedTransport> trans(new TPipedTransport(underlying, pipe)); + stdcxx::shared_ptr<TMemoryBuffer> underlying(new TMemoryBuffer); + stdcxx::shared_ptr<TMemoryBuffer> pipe(new TMemoryBuffer); + stdcxx::shared_ptr<TPipedTransport> trans(new TPipedTransport(underlying, pipe)); uint8_t buffer[4]; diff --git a/lib/cpp/test/TSSLSocketInterruptTest.cpp b/lib/cpp/test/TSSLSocketInterruptTest.cpp index bf5c7d765..85f6c398d 100644 --- a/lib/cpp/test/TSSLSocketInterruptTest.cpp +++ b/lib/cpp/test/TSSLSocketInterruptTest.cpp @@ -19,13 +19,12 @@ #include <boost/test/auto_unit_test.hpp> #include <boost/test/unit_test_suite.hpp> -#include <boost/bind.hpp> #include <boost/chrono/duration.hpp> #include <boost/date_time/posix_time/posix_time_duration.hpp> #include <boost/thread/thread.hpp> #include <boost/filesystem.hpp> #include <boost/format.hpp> -#include <boost/shared_ptr.hpp> +#include <thrift/stdcxx.h> #include <thrift/transport/TSSLSocket.h> #include <thrift/transport/TSSLServerSocket.h> #ifdef __linux__ @@ -38,6 +37,9 @@ using apache::thrift::transport::TTransport; using apache::thrift::transport::TTransportException; using apache::thrift::transport::TSSLSocketFactory; +using apache::thrift::stdcxx::static_pointer_cast; +using apache::thrift::stdcxx::shared_ptr; + BOOST_AUTO_TEST_SUITE(TSSLSocketInterruptTest) boost::filesystem::path keyDir; @@ -92,7 +94,7 @@ BOOST_GLOBAL_FIXTURE(GlobalFixtureSSL); BOOST_GLOBAL_FIXTURE(GlobalFixtureSSL) #endif -void readerWorker(boost::shared_ptr<TTransport> tt, uint32_t expectedResult) { +void readerWorker(shared_ptr<TTransport> tt, uint32_t expectedResult) { uint8_t buf[4]; try { tt->read(buf, 1); @@ -102,7 +104,7 @@ void readerWorker(boost::shared_ptr<TTransport> tt, uint32_t expectedResult) { } } -void readerWorkerMustThrow(boost::shared_ptr<TTransport> tt) { +void readerWorkerMustThrow(shared_ptr<TTransport> tt) { try { uint8_t buf[400]; tt->read(buf, 1); @@ -113,8 +115,8 @@ void readerWorkerMustThrow(boost::shared_ptr<TTransport> tt) { } } -boost::shared_ptr<TSSLSocketFactory> createServerSocketFactory() { - boost::shared_ptr<TSSLSocketFactory> pServerSocketFactory; +shared_ptr<TSSLSocketFactory> createServerSocketFactory() { + shared_ptr<TSSLSocketFactory> pServerSocketFactory; pServerSocketFactory.reset(new TSSLSocketFactory()); pServerSocketFactory->ciphers("ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH"); @@ -124,8 +126,8 @@ boost::shared_ptr<TSSLSocketFactory> createServerSocketFactory() { return pServerSocketFactory; } -boost::shared_ptr<TSSLSocketFactory> createClientSocketFactory() { - boost::shared_ptr<TSSLSocketFactory> pClientSocketFactory; +shared_ptr<TSSLSocketFactory> createClientSocketFactory() { + shared_ptr<TSSLSocketFactory> pClientSocketFactory; pClientSocketFactory.reset(new TSSLSocketFactory()); pClientSocketFactory->authenticate(true); @@ -136,15 +138,15 @@ boost::shared_ptr<TSSLSocketFactory> createClientSocketFactory() { } BOOST_AUTO_TEST_CASE(test_ssl_interruptable_child_read_while_handshaking) { - boost::shared_ptr<TSSLSocketFactory> pServerSocketFactory = createServerSocketFactory(); + shared_ptr<TSSLSocketFactory> pServerSocketFactory = createServerSocketFactory(); TSSLServerSocket sock1("localhost", 0, pServerSocketFactory); sock1.listen(); int port = sock1.getPort(); - boost::shared_ptr<TSSLSocketFactory> pClientSocketFactory = createClientSocketFactory(); - boost::shared_ptr<TSSLSocket> clientSock = pClientSocketFactory->createSocket("localhost", port); + shared_ptr<TSSLSocketFactory> pClientSocketFactory = createClientSocketFactory(); + shared_ptr<TSSLSocket> clientSock = pClientSocketFactory->createSocket("localhost", port); clientSock->open(); - boost::shared_ptr<TTransport> accepted = sock1.accept(); - boost::thread readThread(boost::bind(readerWorkerMustThrow, accepted)); + shared_ptr<TTransport> accepted = sock1.accept(); + boost::thread readThread(apache::thrift::stdcxx::bind(readerWorkerMustThrow, accepted)); boost::this_thread::sleep(boost::posix_time::milliseconds(50)); // readThread is practically guaranteed to be blocking now sock1.interruptChildren(); @@ -156,15 +158,15 @@ BOOST_AUTO_TEST_CASE(test_ssl_interruptable_child_read_while_handshaking) { } BOOST_AUTO_TEST_CASE(test_ssl_interruptable_child_read) { - boost::shared_ptr<TSSLSocketFactory> pServerSocketFactory = createServerSocketFactory(); + shared_ptr<TSSLSocketFactory> pServerSocketFactory = createServerSocketFactory(); TSSLServerSocket sock1("localhost", 0, pServerSocketFactory); sock1.listen(); int port = sock1.getPort(); - boost::shared_ptr<TSSLSocketFactory> pClientSocketFactory = createClientSocketFactory(); - boost::shared_ptr<TSSLSocket> clientSock = pClientSocketFactory->createSocket("localhost", port); + shared_ptr<TSSLSocketFactory> pClientSocketFactory = createClientSocketFactory(); + shared_ptr<TSSLSocket> clientSock = pClientSocketFactory->createSocket("localhost", port); clientSock->open(); - boost::shared_ptr<TTransport> accepted = sock1.accept(); - boost::thread readThread(boost::bind(readerWorkerMustThrow, accepted)); + shared_ptr<TTransport> accepted = sock1.accept(); + boost::thread readThread(apache::thrift::stdcxx::bind(readerWorkerMustThrow, accepted)); clientSock->write((const uint8_t*)"0", 1); boost::this_thread::sleep(boost::posix_time::milliseconds(50)); // readThread is practically guaranteed to be blocking now @@ -177,17 +179,17 @@ BOOST_AUTO_TEST_CASE(test_ssl_interruptable_child_read) { } BOOST_AUTO_TEST_CASE(test_ssl_non_interruptable_child_read) { - boost::shared_ptr<TSSLSocketFactory> pServerSocketFactory = createServerSocketFactory(); + shared_ptr<TSSLSocketFactory> pServerSocketFactory = createServerSocketFactory(); TSSLServerSocket sock1("localhost", 0, pServerSocketFactory); sock1.setInterruptableChildren(false); // returns to pre-THRIFT-2441 behavior sock1.listen(); int port = sock1.getPort(); - boost::shared_ptr<TSSLSocketFactory> pClientSocketFactory = createClientSocketFactory(); - boost::shared_ptr<TSSLSocket> clientSock = pClientSocketFactory->createSocket("localhost", port); + shared_ptr<TSSLSocketFactory> pClientSocketFactory = createClientSocketFactory(); + shared_ptr<TSSLSocket> clientSock = pClientSocketFactory->createSocket("localhost", port); clientSock->open(); - boost::shared_ptr<TTransport> accepted = sock1.accept(); - boost::static_pointer_cast<TSSLSocket>(accepted)->setRecvTimeout(1000); - boost::thread readThread(boost::bind(readerWorker, accepted, 0)); + shared_ptr<TTransport> accepted = sock1.accept(); + static_pointer_cast<TSSLSocket>(accepted)->setRecvTimeout(1000); + boost::thread readThread(apache::thrift::stdcxx::bind(readerWorker, accepted, 0)); clientSock->write((const uint8_t*)"0", 1); boost::this_thread::sleep(boost::posix_time::milliseconds(50)); // readThread is practically guaranteed to be blocking here @@ -203,14 +205,14 @@ BOOST_AUTO_TEST_CASE(test_ssl_non_interruptable_child_read) { } BOOST_AUTO_TEST_CASE(test_ssl_cannot_change_after_listen) { - boost::shared_ptr<TSSLSocketFactory> pServerSocketFactory = createServerSocketFactory(); + shared_ptr<TSSLSocketFactory> pServerSocketFactory = createServerSocketFactory(); TSSLServerSocket sock1("localhost", 0, pServerSocketFactory); sock1.listen(); BOOST_CHECK_THROW(sock1.setInterruptableChildren(false), std::logic_error); sock1.close(); } -void peekerWorker(boost::shared_ptr<TTransport> tt, bool expectedResult) { +void peekerWorker(shared_ptr<TTransport> tt, bool expectedResult) { uint8_t buf[400]; try { tt->read(buf, 1); @@ -220,7 +222,7 @@ void peekerWorker(boost::shared_ptr<TTransport> tt, bool expectedResult) { } } -void peekerWorkerInterrupt(boost::shared_ptr<TTransport> tt) { +void peekerWorkerInterrupt(shared_ptr<TTransport> tt) { uint8_t buf[400]; try { tt->read(buf, 1); @@ -231,15 +233,15 @@ void peekerWorkerInterrupt(boost::shared_ptr<TTransport> tt) { } BOOST_AUTO_TEST_CASE(test_ssl_interruptable_child_peek) { - boost::shared_ptr<TSSLSocketFactory> pServerSocketFactory = createServerSocketFactory(); + shared_ptr<TSSLSocketFactory> pServerSocketFactory = createServerSocketFactory(); TSSLServerSocket sock1("localhost", 0, pServerSocketFactory); sock1.listen(); int port = sock1.getPort(); - boost::shared_ptr<TSSLSocketFactory> pClientSocketFactory = createClientSocketFactory(); - boost::shared_ptr<TSSLSocket> clientSock = pClientSocketFactory->createSocket("localhost", port); + shared_ptr<TSSLSocketFactory> pClientSocketFactory = createClientSocketFactory(); + shared_ptr<TSSLSocket> clientSock = pClientSocketFactory->createSocket("localhost", port); clientSock->open(); - boost::shared_ptr<TTransport> accepted = sock1.accept(); - boost::thread peekThread(boost::bind(peekerWorkerInterrupt, accepted)); + shared_ptr<TTransport> accepted = sock1.accept(); + boost::thread peekThread(apache::thrift::stdcxx::bind(peekerWorkerInterrupt, accepted)); clientSock->write((const uint8_t*)"0", 1); boost::this_thread::sleep(boost::posix_time::milliseconds(50)); // peekThread is practically guaranteed to be blocking now @@ -252,17 +254,17 @@ BOOST_AUTO_TEST_CASE(test_ssl_interruptable_child_peek) { } BOOST_AUTO_TEST_CASE(test_ssl_non_interruptable_child_peek) { - boost::shared_ptr<TSSLSocketFactory> pServerSocketFactory = createServerSocketFactory(); + shared_ptr<TSSLSocketFactory> pServerSocketFactory = createServerSocketFactory(); TSSLServerSocket sock1("localhost", 0, pServerSocketFactory); sock1.setInterruptableChildren(false); // returns to pre-THRIFT-2441 behavior sock1.listen(); int port = sock1.getPort(); - boost::shared_ptr<TSSLSocketFactory> pClientSocketFactory = createClientSocketFactory(); - boost::shared_ptr<TSSLSocket> clientSock = pClientSocketFactory->createSocket("localhost", port); + shared_ptr<TSSLSocketFactory> pClientSocketFactory = createClientSocketFactory(); + shared_ptr<TSSLSocket> clientSock = pClientSocketFactory->createSocket("localhost", port); clientSock->open(); - boost::shared_ptr<TTransport> accepted = sock1.accept(); - boost::static_pointer_cast<TSSLSocket>(accepted)->setRecvTimeout(1000); - boost::thread peekThread(boost::bind(peekerWorker, accepted, false)); + shared_ptr<TTransport> accepted = sock1.accept(); + static_pointer_cast<TSSLSocket>(accepted)->setRecvTimeout(1000); + boost::thread peekThread(apache::thrift::stdcxx::bind(peekerWorker, accepted, false)); clientSock->write((const uint8_t*)"0", 1); boost::this_thread::sleep(boost::posix_time::milliseconds(50)); // peekThread is practically guaranteed to be blocking now diff --git a/lib/cpp/test/TServerIntegrationTest.cpp b/lib/cpp/test/TServerIntegrationTest.cpp index fd7bae2ff..a6e02f1ba 100644 --- a/lib/cpp/test/TServerIntegrationTest.cpp +++ b/lib/cpp/test/TServerIntegrationTest.cpp @@ -20,16 +20,14 @@ #define BOOST_TEST_MODULE TServerIntegrationTest #include <boost/test/auto_unit_test.hpp> #include <boost/atomic.hpp> -#include <boost/bind.hpp> #include <boost/date_time/posix_time/ptime.hpp> #include <boost/foreach.hpp> #include <boost/format.hpp> -#include <boost/make_shared.hpp> -#include <boost/shared_ptr.hpp> #include <boost/thread.hpp> #include <thrift/server/TSimpleServer.h> #include <thrift/server/TThreadPoolServer.h> #include <thrift/server/TThreadedServer.h> +#include <thrift/stdcxx.h> #include <thrift/protocol/TBinaryProtocol.h> #include <thrift/transport/TServerSocket.h> #include <thrift/transport/TSocket.h> @@ -57,6 +55,9 @@ using apache::thrift::server::TServerEventHandler; using apache::thrift::server::TSimpleServer; using apache::thrift::server::TThreadPoolServer; using apache::thrift::server::TThreadedServer; +using apache::thrift::stdcxx::dynamic_pointer_cast; +using apache::thrift::stdcxx::make_shared; +using apache::thrift::stdcxx::shared_ptr; using apache::thrift::test::ParentServiceClient; using apache::thrift::test::ParentServiceIf; using apache::thrift::test::ParentServiceIfFactory; @@ -79,8 +80,8 @@ public: isListening_ = true; notify(); } - virtual void* createContext(boost::shared_ptr<TProtocol> input, - boost::shared_ptr<TProtocol> output) { + virtual void* createContext(shared_ptr<TProtocol> input, + shared_ptr<TProtocol> output) { Synchronized sync(*this); ++accepted_; notify(); @@ -149,26 +150,26 @@ void autoSocketCloser(TSocket* pSock) { template <class TServerType> class TServerIntegrationTestFixture { public: - TServerIntegrationTestFixture(const boost::shared_ptr<TProcessorFactory>& _processorFactory) + TServerIntegrationTestFixture(const shared_ptr<TProcessorFactory>& _processorFactory) : pServer(new TServerType(_processorFactory, - boost::shared_ptr<TServerTransport>( + shared_ptr<TServerTransport>( new TServerSocket("localhost", 0)), - boost::shared_ptr<TTransportFactory>(new TTransportFactory), - boost::shared_ptr<TProtocolFactory>(new TBinaryProtocolFactory))), - pEventHandler(boost::shared_ptr<TServerReadyEventHandler>(new TServerReadyEventHandler)), + shared_ptr<TTransportFactory>(new TTransportFactory), + shared_ptr<TProtocolFactory>(new TBinaryProtocolFactory))), + pEventHandler(shared_ptr<TServerReadyEventHandler>(new TServerReadyEventHandler)), bStressDone(false), bStressConnectionCount(0), bStressRequestCount(0) { pServer->setServerEventHandler(pEventHandler); } - TServerIntegrationTestFixture(const boost::shared_ptr<TProcessor>& _processor) + TServerIntegrationTestFixture(const shared_ptr<TProcessor>& _processor) : pServer( new TServerType(_processor, - boost::shared_ptr<TServerTransport>(new TServerSocket("localhost", 0)), - boost::shared_ptr<TTransportFactory>(new TTransportFactory), - boost::shared_ptr<TProtocolFactory>(new TBinaryProtocolFactory))), - pEventHandler(boost::shared_ptr<TServerReadyEventHandler>(new TServerReadyEventHandler)), + shared_ptr<TServerTransport>(new TServerSocket("localhost", 0)), + shared_ptr<TTransportFactory>(new TTransportFactory), + shared_ptr<TProtocolFactory>(new TBinaryProtocolFactory))), + pEventHandler(shared_ptr<TServerReadyEventHandler>(new TServerReadyEventHandler)), bStressDone(false), bStressConnectionCount(0), bStressRequestCount(0) { @@ -176,7 +177,7 @@ public: } void startServer() { - pServerThread.reset(new boost::thread(boost::bind(&TServerType::serve, pServer.get()))); + pServerThread.reset(new boost::thread(apache::thrift::stdcxx::bind(&TServerType::serve, pServer.get()))); // block until listen() completes so clients will be able to connect Synchronized sync(*(pEventHandler.get())); @@ -222,19 +223,19 @@ public: startServer(); - std::vector<boost::shared_ptr<TSocket> > holdSockets; - std::vector<boost::shared_ptr<boost::thread> > holdThreads; + std::vector<shared_ptr<TSocket> > holdSockets; + std::vector<shared_ptr<boost::thread> > holdThreads; for (int64_t i = 0; i < numToMake; ++i) { - boost::shared_ptr<TSocket> pClientSock(new TSocket("localhost", getServerPort()), + shared_ptr<TSocket> pClientSock(new TSocket("localhost", getServerPort()), autoSocketCloser); holdSockets.push_back(pClientSock); - boost::shared_ptr<TProtocol> pClientProtocol(new TBinaryProtocol(pClientSock)); + shared_ptr<TProtocol> pClientProtocol(new TBinaryProtocol(pClientSock)); ParentServiceClient client(pClientProtocol); pClientSock->open(); client.incrementGeneration(); - holdThreads.push_back(boost::shared_ptr<boost::thread>( - new boost::thread(boost::bind(&TServerIntegrationTestFixture::delayClose, + holdThreads.push_back(shared_ptr<boost::thread>( + new boost::thread(apache::thrift::stdcxx::bind(&TServerIntegrationTestFixture::delayClose, this, pClientSock, milliseconds(10 * numToMake))))); @@ -242,7 +243,7 @@ public: BOOST_CHECK_EQUAL(expectedHWM, pServer->getConcurrentClientCountHWM()); - BOOST_FOREACH (boost::shared_ptr<boost::thread> pThread, holdThreads) { pThread->join(); } + BOOST_FOREACH (shared_ptr<boost::thread> pThread, holdThreads) { pThread->join(); } holdThreads.clear(); holdSockets.clear(); @@ -254,7 +255,7 @@ public: * \param[in] toClose the connection to close * \param[in] after the delay to impose */ - void delayClose(boost::shared_ptr<TTransport> toClose, boost::posix_time::time_duration after) { + void delayClose(shared_ptr<TTransport> toClose, boost::posix_time::time_duration after) { boost::this_thread::sleep(after); toClose->close(); } @@ -279,10 +280,10 @@ public: startServer(); - std::vector<boost::shared_ptr<boost::thread> > holdThreads; + std::vector<shared_ptr<boost::thread> > holdThreads; for (int64_t i = 0; i < numToMake; ++i) { - holdThreads.push_back(boost::shared_ptr<boost::thread>( - new boost::thread(boost::bind(&TServerIntegrationTestFixture::stressor, this)))); + holdThreads.push_back(shared_ptr<boost::thread>( + new boost::thread(apache::thrift::stdcxx::bind(&TServerIntegrationTestFixture::stressor, this)))); } boost::this_thread::sleep(duration); @@ -291,7 +292,7 @@ public: BOOST_TEST_MESSAGE(boost::format(" serviced %1% connections (HWM %2%) totaling %3% requests") % bStressConnectionCount % pServer->getConcurrentClientCountHWM() % bStressRequestCount); - BOOST_FOREACH (boost::shared_ptr<boost::thread> pThread, holdThreads) { pThread->join(); } + BOOST_FOREACH (shared_ptr<boost::thread> pThread, holdThreads) { pThread->join(); } holdThreads.clear(); BOOST_CHECK(bStressRequestCount > 0); @@ -304,8 +305,8 @@ public: */ void stressor() { while (!bStressDone) { - boost::shared_ptr<TSocket> pSocket(new TSocket("localhost", getServerPort()), autoSocketCloser); - boost::shared_ptr<TProtocol> pProtocol(new TBinaryProtocol(pSocket)); + shared_ptr<TSocket> pSocket(new TSocket("localhost", getServerPort()), autoSocketCloser); + shared_ptr<TProtocol> pProtocol(new TBinaryProtocol(pSocket)); ParentServiceClient client(pProtocol); pSocket->open(); bStressConnectionCount.fetch_add(1, boost::memory_order_relaxed); @@ -316,9 +317,9 @@ public: } } - boost::shared_ptr<TServerType> pServer; - boost::shared_ptr<TServerReadyEventHandler> pEventHandler; - boost::shared_ptr<boost::thread> pServerThread; + shared_ptr<TServerType> pServer; + shared_ptr<TServerReadyEventHandler> pEventHandler; + shared_ptr<boost::thread> pServerThread; bool bStressDone; boost::atomic_int64_t bStressConnectionCount; boost::atomic_int64_t bStressRequestCount; @@ -329,9 +330,9 @@ class TServerIntegrationProcessorFactoryTestFixture : public TServerIntegrationTestFixture<TServerType> { public: TServerIntegrationProcessorFactoryTestFixture() - : TServerIntegrationTestFixture<TServerType>(boost::make_shared<ParentServiceProcessorFactory>( - boost::make_shared<ParentServiceIfSingletonFactory>( - boost::make_shared<ParentHandler>()))) {} + : TServerIntegrationTestFixture<TServerType>(make_shared<ParentServiceProcessorFactory>( + make_shared<ParentServiceIfSingletonFactory>( + make_shared<ParentHandler>()))) {} }; template <class TServerType> @@ -339,7 +340,7 @@ class TServerIntegrationProcessorTestFixture : public TServerIntegrationTestFixt public: TServerIntegrationProcessorTestFixture() : TServerIntegrationTestFixture<TServerType>( - boost::make_shared<ParentServiceProcessor>(boost::make_shared<ParentHandler>())) {} + make_shared<ParentServiceProcessor>(make_shared<ParentHandler>())) {} }; BOOST_AUTO_TEST_SUITE(constructors) @@ -376,7 +377,7 @@ BOOST_FIXTURE_TEST_CASE(test_threaded_stress, BOOST_FIXTURE_TEST_CASE(test_threadpool_factory, TServerIntegrationProcessorFactoryTestFixture<TThreadPoolServer>) { pServer->getThreadManager()->threadFactory( - boost::shared_ptr<apache::thrift::concurrency::ThreadFactory>( + shared_ptr<apache::thrift::concurrency::ThreadFactory>( new apache::thrift::concurrency::PlatformThreadFactory)); pServer->getThreadManager()->start(); @@ -391,7 +392,7 @@ BOOST_FIXTURE_TEST_CASE(test_threadpool_factory, BOOST_FIXTURE_TEST_CASE(test_threadpool, TServerIntegrationProcessorTestFixture<TThreadPoolServer>) { pServer->getThreadManager()->threadFactory( - boost::shared_ptr<apache::thrift::concurrency::ThreadFactory>( + shared_ptr<apache::thrift::concurrency::ThreadFactory>( new apache::thrift::concurrency::PlatformThreadFactory)); pServer->getThreadManager()->start(); @@ -406,7 +407,7 @@ BOOST_FIXTURE_TEST_CASE(test_threadpool, BOOST_FIXTURE_TEST_CASE(test_threadpool_bound, TServerIntegrationProcessorTestFixture<TThreadPoolServer>) { pServer->getThreadManager()->threadFactory( - boost::shared_ptr<apache::thrift::concurrency::ThreadFactory>( + shared_ptr<apache::thrift::concurrency::ThreadFactory>( new apache::thrift::concurrency::PlatformThreadFactory)); pServer->getThreadManager()->start(); pServer->setConcurrentClientLimit(4); @@ -417,7 +418,7 @@ BOOST_FIXTURE_TEST_CASE(test_threadpool_bound, BOOST_FIXTURE_TEST_CASE(test_threadpool_stress, TServerIntegrationProcessorTestFixture<TThreadPoolServer>) { pServer->getThreadManager()->threadFactory( - boost::shared_ptr<apache::thrift::concurrency::ThreadFactory>( + shared_ptr<apache::thrift::concurrency::ThreadFactory>( new apache::thrift::concurrency::PlatformThreadFactory)); pServer->getThreadManager()->start(); @@ -435,11 +436,11 @@ BOOST_AUTO_TEST_CASE(test_stop_with_interruptable_clients_connected) { startServer(); - boost::shared_ptr<TSocket> pClientSock1(new TSocket("localhost", getServerPort()), + shared_ptr<TSocket> pClientSock1(new TSocket("localhost", getServerPort()), autoSocketCloser); pClientSock1->open(); - boost::shared_ptr<TSocket> pClientSock2(new TSocket("localhost", getServerPort()), + shared_ptr<TSocket> pClientSock2(new TSocket("localhost", getServerPort()), autoSocketCloser); pClientSock2->open(); @@ -461,27 +462,27 @@ BOOST_AUTO_TEST_CASE(test_stop_with_uninterruptable_clients_connected) { // disconnect. BOOST_TEST_MESSAGE("Testing stop with uninterruptable clients"); - boost::dynamic_pointer_cast<TServerSocket>(pServer->getServerTransport()) + dynamic_pointer_cast<TServerSocket>(pServer->getServerTransport()) ->setInterruptableChildren(false); // returns to pre-THRIFT-2441 behavior startServer(); - boost::shared_ptr<TSocket> pClientSock1(new TSocket("localhost", getServerPort()), + shared_ptr<TSocket> pClientSock1(new TSocket("localhost", getServerPort()), autoSocketCloser); pClientSock1->open(); - boost::shared_ptr<TSocket> pClientSock2(new TSocket("localhost", getServerPort()), + shared_ptr<TSocket> pClientSock2(new TSocket("localhost", getServerPort()), autoSocketCloser); pClientSock2->open(); // Ensure they have been accepted blockUntilAccepted(2); - boost::thread t1(boost::bind(&TServerIntegrationTestFixture::delayClose, + boost::thread t1(apache::thrift::stdcxx::bind(&TServerIntegrationTestFixture::delayClose, this, pClientSock1, milliseconds(250))); - boost::thread t2(boost::bind(&TServerIntegrationTestFixture::delayClose, + boost::thread t2(apache::thrift::stdcxx::bind(&TServerIntegrationTestFixture::delayClose, this, pClientSock2, milliseconds(250))); @@ -502,24 +503,24 @@ BOOST_AUTO_TEST_CASE(test_concurrent_client_limit) { BOOST_CHECK_EQUAL(0, pServer->getConcurrentClientCount()); BOOST_CHECK_EQUAL(2, pServer->getConcurrentClientLimit()); - boost::shared_ptr<TSocket> pClientSock1(new TSocket("localhost", getServerPort()), + shared_ptr<TSocket> pClientSock1(new TSocket("localhost", getServerPort()), autoSocketCloser); pClientSock1->open(); blockUntilAccepted(1); BOOST_CHECK_EQUAL(1, pServer->getConcurrentClientCount()); - boost::shared_ptr<TSocket> pClientSock2(new TSocket("localhost", getServerPort()), + shared_ptr<TSocket> pClientSock2(new TSocket("localhost", getServerPort()), autoSocketCloser); pClientSock2->open(); blockUntilAccepted(2); BOOST_CHECK_EQUAL(2, pServer->getConcurrentClientCount()); // a third client cannot connect until one of the other two closes - boost::thread t2(boost::bind(&TServerIntegrationTestFixture::delayClose, + boost::thread t2(apache::thrift::stdcxx::bind(&TServerIntegrationTestFixture::delayClose, this, pClientSock2, milliseconds(250))); - boost::shared_ptr<TSocket> pClientSock3(new TSocket("localhost", getServerPort()), + shared_ptr<TSocket> pClientSock3(new TSocket("localhost", getServerPort()), autoSocketCloser); pClientSock2->open(); blockUntilAccepted(2); diff --git a/lib/cpp/test/TServerSocketTest.cpp b/lib/cpp/test/TServerSocketTest.cpp index 1da5d36ec..a191147eb 100644 --- a/lib/cpp/test/TServerSocketTest.cpp +++ b/lib/cpp/test/TServerSocketTest.cpp @@ -20,6 +20,7 @@ #include <boost/test/auto_unit_test.hpp> #include <thrift/transport/TSocket.h> #include <thrift/transport/TServerSocket.h> +#include <thrift/stdcxx.h> #include "TTransportCheckThrow.h" #include <iostream> @@ -27,6 +28,7 @@ using apache::thrift::transport::TServerSocket; using apache::thrift::transport::TSocket; using apache::thrift::transport::TTransport; using apache::thrift::transport::TTransportException; +using apache::thrift::stdcxx::shared_ptr; BOOST_AUTO_TEST_SUITE(TServerSocketTest) @@ -36,7 +38,7 @@ BOOST_AUTO_TEST_CASE(test_bind_to_address) { int port = sock1.getPort(); TSocket clientSock("localhost", port); clientSock.open(); - boost::shared_ptr<TTransport> accepted = sock1.accept(); + shared_ptr<TTransport> accepted = sock1.accept(); accepted->close(); sock1.close(); diff --git a/lib/cpp/test/TServerTransportTest.cpp b/lib/cpp/test/TServerTransportTest.cpp index a55462269..dc6aede87 100644 --- a/lib/cpp/test/TServerTransportTest.cpp +++ b/lib/cpp/test/TServerTransportTest.cpp @@ -20,10 +20,12 @@ #include <boost/test/auto_unit_test.hpp> #include <thrift/transport/TSocket.h> #include <thrift/transport/TServerTransport.h> +#include <thrift/stdcxx.h> using apache::thrift::transport::TServerTransport; using apache::thrift::transport::TTransport; using apache::thrift::transport::TTransportException; +using apache::thrift::stdcxx::shared_ptr; BOOST_AUTO_TEST_SUITE(TServerTransportTest) @@ -36,9 +38,9 @@ public: bool valid_; protected: - boost::shared_ptr<TTransport> acceptImpl() { - return valid_ ? boost::shared_ptr<TestTTransport>(new TestTTransport) - : boost::shared_ptr<TestTTransport>(); + shared_ptr<TTransport> acceptImpl() { + return valid_ ? shared_ptr<TestTTransport>(new TestTTransport) + : shared_ptr<TestTTransport>(); } }; diff --git a/lib/cpp/test/TSocketInterruptTest.cpp b/lib/cpp/test/TSocketInterruptTest.cpp index 27b89ebe6..3a189cce5 100644 --- a/lib/cpp/test/TSocketInterruptTest.cpp +++ b/lib/cpp/test/TSocketInterruptTest.cpp @@ -20,26 +20,27 @@ #define BOOST_TEST_MODULE TSocketInterruptTest #include <boost/test/auto_unit_test.hpp> -#include <boost/bind.hpp> #include <boost/chrono/duration.hpp> #include <boost/date_time/posix_time/posix_time_duration.hpp> #include <boost/thread/thread.hpp> #include <thrift/transport/TSocket.h> #include <thrift/transport/TServerSocket.h> +#include <thrift/stdcxx.h> using apache::thrift::transport::TServerSocket; using apache::thrift::transport::TSocket; using apache::thrift::transport::TTransport; using apache::thrift::transport::TTransportException; +using namespace apache::thrift; BOOST_AUTO_TEST_SUITE(TSocketInterruptTest) -void readerWorker(boost::shared_ptr<TTransport> tt, uint32_t expectedResult) { +void readerWorker(stdcxx::shared_ptr<TTransport> tt, uint32_t expectedResult) { uint8_t buf[4]; BOOST_CHECK_EQUAL(expectedResult, tt->read(buf, 4)); } -void readerWorkerMustThrow(boost::shared_ptr<TTransport> tt) { +void readerWorkerMustThrow(stdcxx::shared_ptr<TTransport> tt) { try { uint8_t buf[4]; tt->read(buf, 4); @@ -55,8 +56,8 @@ BOOST_AUTO_TEST_CASE(test_interruptable_child_read) { int port = sock1.getPort(); TSocket clientSock("localhost", port); clientSock.open(); - boost::shared_ptr<TTransport> accepted = sock1.accept(); - boost::thread readThread(boost::bind(readerWorkerMustThrow, accepted)); + stdcxx::shared_ptr<TTransport> accepted = sock1.accept(); + boost::thread readThread(stdcxx::bind(readerWorkerMustThrow, accepted)); boost::this_thread::sleep(boost::posix_time::milliseconds(50)); // readThread is practically guaranteed to be blocking now sock1.interruptChildren(); @@ -74,8 +75,8 @@ BOOST_AUTO_TEST_CASE(test_non_interruptable_child_read) { int port = sock1.getPort(); TSocket clientSock("localhost", port); clientSock.open(); - boost::shared_ptr<TTransport> accepted = sock1.accept(); - boost::thread readThread(boost::bind(readerWorker, accepted, 0)); + stdcxx::shared_ptr<TTransport> accepted = sock1.accept(); + boost::thread readThread(stdcxx::bind(readerWorker, accepted, 0)); boost::this_thread::sleep(boost::posix_time::milliseconds(50)); // readThread is practically guaranteed to be blocking here sock1.interruptChildren(); @@ -96,7 +97,7 @@ BOOST_AUTO_TEST_CASE(test_cannot_change_after_listen) { sock1.close(); } -void peekerWorker(boost::shared_ptr<TTransport> tt, bool expectedResult) { +void peekerWorker(stdcxx::shared_ptr<TTransport> tt, bool expectedResult) { BOOST_CHECK_EQUAL(expectedResult, tt->peek()); } @@ -106,9 +107,9 @@ BOOST_AUTO_TEST_CASE(test_interruptable_child_peek) { int port = sock1.getPort(); TSocket clientSock("localhost", port); clientSock.open(); - boost::shared_ptr<TTransport> accepted = sock1.accept(); + stdcxx::shared_ptr<TTransport> accepted = sock1.accept(); // peek() will return false if child is interrupted - boost::thread peekThread(boost::bind(peekerWorker, accepted, false)); + boost::thread peekThread(stdcxx::bind(peekerWorker, accepted, false)); boost::this_thread::sleep(boost::posix_time::milliseconds(50)); // peekThread is practically guaranteed to be blocking now sock1.interruptChildren(); @@ -126,9 +127,9 @@ BOOST_AUTO_TEST_CASE(test_non_interruptable_child_peek) { int port = sock1.getPort(); TSocket clientSock("localhost", port); clientSock.open(); - boost::shared_ptr<TTransport> accepted = sock1.accept(); + stdcxx::shared_ptr<TTransport> accepted = sock1.accept(); // peek() will return false when remote side is closed - boost::thread peekThread(boost::bind(peekerWorker, accepted, false)); + boost::thread peekThread(stdcxx::bind(peekerWorker, accepted, false)); boost::this_thread::sleep(boost::posix_time::milliseconds(50)); // peekThread is practically guaranteed to be blocking now sock1.interruptChildren(); diff --git a/lib/cpp/test/TransportTest.cpp b/lib/cpp/test/TransportTest.cpp index ccef9d5fb..d6ab457e2 100644 --- a/lib/cpp/test/TransportTest.cpp +++ b/lib/cpp/test/TransportTest.cpp @@ -26,7 +26,7 @@ #endif #include <sstream> #include <fstream> -#include <thrift/cxxfunctional.h> +#include <thrift/stdcxx.h> #include <boost/mpl/list.hpp> #include <boost/shared_array.hpp> @@ -43,10 +43,12 @@ #include <thrift/concurrency/FunctionRunner.h> #if _WIN32 +#include <thrift/transport/TPipe.h> #include <thrift/windows/TWinsockSingleton.h> #endif using namespace apache::thrift::transport; +using namespace apache::thrift; static boost::mt19937 rng; @@ -112,7 +114,7 @@ public: std::string describe() const { return generator_->describe(); } private: - boost::shared_ptr<SizeGenerator> generator_; + stdcxx::shared_ptr<SizeGenerator> generator_; }; /************************************************************************** @@ -135,8 +137,8 @@ public: CoupledTransports() : in(), out() {} - boost::shared_ptr<Transport_> in; - boost::shared_ptr<Transport_> out; + stdcxx::shared_ptr<Transport_> in; + stdcxx::shared_ptr<Transport_> out; private: CoupledTransports(const CoupledTransports&); @@ -153,7 +155,7 @@ public: out = buf; } - boost::shared_ptr<TMemoryBuffer> buf; + stdcxx::shared_ptr<TMemoryBuffer> buf; }; /** @@ -219,6 +221,22 @@ public: out.reset(new TFDTransport(pipes[1], TFDTransport::CLOSE_ON_DESTROY)); } }; +#else +/** + * Coupled pipe transports + */ +class CoupledPipeTransports : public CoupledTransports<TPipe> { +public: + HANDLE hRead; + HANDLE hWrite; + + CoupledPipeTransports() { + BOOST_REQUIRE(CreatePipe(&hRead, &hWrite, NULL, 1048576 * 2)); + in.reset(new TPipe(hRead, hWrite)); + in->open(); + out = in; + } +}; #endif /** @@ -323,11 +341,11 @@ public: **************************************************************************/ struct TriggerInfo { - TriggerInfo(int seconds, const boost::shared_ptr<TTransport>& transport, uint32_t writeLength) + TriggerInfo(int seconds, const stdcxx::shared_ptr<TTransport>& transport, uint32_t writeLength) : timeoutSeconds(seconds), transport(transport), writeLength(writeLength), next(NULL) {} int timeoutSeconds; - boost::shared_ptr<TTransport> transport; + stdcxx::shared_ptr<TTransport> transport; uint32_t writeLength; TriggerInfo* next; }; @@ -402,7 +420,7 @@ void alarm_handler_wrapper() { * to the end.) */ void add_trigger(unsigned int seconds, - const boost::shared_ptr<TTransport>& transport, + const stdcxx::shared_ptr<TTransport>& transport, uint32_t write_len) { TriggerInfo* info = new TriggerInfo(seconds, transport, write_len); { @@ -442,7 +460,7 @@ void clear_triggers() { } void set_trigger(unsigned int seconds, - const boost::shared_ptr<TTransport>& transport, + const stdcxx::shared_ptr<TTransport>& transport, uint32_t write_len) { clear_triggers(); add_trigger(seconds, transport, write_len); @@ -840,6 +858,19 @@ public: TEST_RW(CoupledFDTransports, 1024 * 16, 1, 1, rand4k, rand4k, fd_max_outstanding); TEST_BLOCKING_BEHAVIOR(CoupledFDTransports); +#else + // TPipe tests (WIN32 only) + TEST_RW(CoupledPipeTransports, 1024 * 1024, 0, 0); + TEST_RW(CoupledPipeTransports, 1024 * 256, rand4k, rand4k); + TEST_RW(CoupledPipeTransports, 1024 * 256, 167, 163); + TEST_RW(CoupledPipeTransports, 1024 * 16, 1, 1); + + TEST_RW(CoupledPipeTransports, 1024 * 256, 0, 0, rand4k, rand4k); + TEST_RW(CoupledPipeTransports, 1024 * 256, rand4k, rand4k, rand4k, rand4k); + TEST_RW(CoupledPipeTransports, 1024 * 256, 167, 163, rand4k, rand4k); + TEST_RW(CoupledPipeTransports, 1024 * 16, 1, 1, rand4k, rand4k); + + TEST_BLOCKING_BEHAVIOR(CoupledPipeTransports); #endif //_WIN32 // TSocket tests @@ -945,11 +976,11 @@ private: << rChunkSizeGen.describe() << ", " << maxOutstanding << ")"; #if (BOOST_VERSION >= 105900) - boost::function<void ()> test_func + stdcxx::function<void ()> test_func #else boost::unit_test::callback0<> test_func #endif - = apache::thrift::stdcxx::bind(test_rw<CoupledTransports>, + = stdcxx::bind(test_rw<CoupledTransports>, totalSize, wSizeGen, rSizeGen, @@ -995,7 +1026,7 @@ private: **************************************************************************/ struct global_fixture { - boost::shared_ptr<apache::thrift::concurrency::Thread> alarmThread_; + stdcxx::shared_ptr<apache::thrift::concurrency::Thread> alarmThread_; global_fixture() { #if _WIN32 apache::thrift::transport::TWinsockSingleton::create(); diff --git a/lib/cpp/test/ZlibTest.cpp b/lib/cpp/test/ZlibTest.cpp index 25db4b8f5..a4479eb5a 100644 --- a/lib/cpp/test/ZlibTest.cpp +++ b/lib/cpp/test/ZlibTest.cpp @@ -36,9 +36,8 @@ #include <cstddef> #include <fstream> #include <iostream> -#include <thrift/cxxfunctional.h> +#include <thrift/stdcxx.h> -#include <boost/function.hpp> #include <boost/random.hpp> #include <boost/shared_array.hpp> #include <boost/test/unit_test.hpp> @@ -47,8 +46,9 @@ #include <thrift/transport/TBufferTransports.h> #include <thrift/transport/TZlibTransport.h> -using namespace std; using namespace apache::thrift::transport; +using apache::thrift::stdcxx::shared_ptr; +using std::string; boost::mt19937 rng; @@ -147,8 +147,8 @@ boost::shared_array<uint8_t> gen_random_buffer(uint32_t buf_len) { */ void test_write_then_read(const boost::shared_array<uint8_t> buf, uint32_t buf_len) { - boost::shared_ptr<TMemoryBuffer> membuf(new TMemoryBuffer()); - boost::shared_ptr<TZlibTransport> zlib_trans(new TZlibTransport(membuf)); + shared_ptr<TMemoryBuffer> membuf(new TMemoryBuffer()); + shared_ptr<TZlibTransport> zlib_trans(new TZlibTransport(membuf)); zlib_trans->write(buf.get(), buf_len); zlib_trans->finish(); @@ -166,8 +166,8 @@ void test_separate_checksum(const boost::shared_array<uint8_t> buf, uint32_t buf // it isn't there. The original implementation complained that // the stream was not complete. I'm about to go fix that. // It worked. Awesome. - boost::shared_ptr<TMemoryBuffer> membuf(new TMemoryBuffer()); - boost::shared_ptr<TZlibTransport> zlib_trans(new TZlibTransport(membuf)); + shared_ptr<TMemoryBuffer> membuf(new TMemoryBuffer()); + shared_ptr<TZlibTransport> zlib_trans(new TZlibTransport(membuf)); zlib_trans->write(buf.get(), buf_len); zlib_trans->finish(); string tmp_buf; @@ -186,8 +186,8 @@ void test_separate_checksum(const boost::shared_array<uint8_t> buf, uint32_t buf void test_incomplete_checksum(const boost::shared_array<uint8_t> buf, uint32_t buf_len) { // Make sure we still get that "not complete" error if // it really isn't complete. - boost::shared_ptr<TMemoryBuffer> membuf(new TMemoryBuffer()); - boost::shared_ptr<TZlibTransport> zlib_trans(new TZlibTransport(membuf)); + shared_ptr<TMemoryBuffer> membuf(new TMemoryBuffer()); + shared_ptr<TZlibTransport> zlib_trans(new TZlibTransport(membuf)); zlib_trans->write(buf.get(), buf_len); zlib_trans->finish(); string tmp_buf; @@ -210,11 +210,11 @@ void test_incomplete_checksum(const boost::shared_array<uint8_t> buf, uint32_t b void test_read_write_mix(const boost::shared_array<uint8_t> buf, uint32_t buf_len, - const boost::shared_ptr<SizeGenerator>& write_gen, - const boost::shared_ptr<SizeGenerator>& read_gen) { + const shared_ptr<SizeGenerator>& write_gen, + const shared_ptr<SizeGenerator>& read_gen) { // Try it with a mix of read/write sizes. - boost::shared_ptr<TMemoryBuffer> membuf(new TMemoryBuffer()); - boost::shared_ptr<TZlibTransport> zlib_trans(new TZlibTransport(membuf)); + shared_ptr<TMemoryBuffer> membuf(new TMemoryBuffer()); + shared_ptr<TZlibTransport> zlib_trans(new TZlibTransport(membuf)); unsigned int tot; tot = 0; @@ -249,8 +249,8 @@ void test_read_write_mix(const boost::shared_array<uint8_t> buf, void test_invalid_checksum(const boost::shared_array<uint8_t> buf, uint32_t buf_len) { // Verify checksum checking. - boost::shared_ptr<TMemoryBuffer> membuf(new TMemoryBuffer()); - boost::shared_ptr<TZlibTransport> zlib_trans(new TZlibTransport(membuf)); + shared_ptr<TMemoryBuffer> membuf(new TMemoryBuffer()); + shared_ptr<TZlibTransport> zlib_trans(new TZlibTransport(membuf)); zlib_trans->write(buf.get(), buf_len); zlib_trans->finish(); string tmp_buf; @@ -286,8 +286,8 @@ void test_invalid_checksum(const boost::shared_array<uint8_t> buf, uint32_t buf_ void test_write_after_flush(const boost::shared_array<uint8_t> buf, uint32_t buf_len) { // write some data - boost::shared_ptr<TMemoryBuffer> membuf(new TMemoryBuffer()); - boost::shared_ptr<TZlibTransport> zlib_trans(new TZlibTransport(membuf)); + shared_ptr<TMemoryBuffer> membuf(new TMemoryBuffer()); + shared_ptr<TZlibTransport> zlib_trans(new TZlibTransport(membuf)); zlib_trans->write(buf.get(), buf_len); // call finish() @@ -322,7 +322,7 @@ void test_write_after_flush(const boost::shared_array<uint8_t> buf, uint32_t buf void test_no_write() { // Verify that no data is written to the underlying transport if we // never write data to the TZlibTransport. - boost::shared_ptr<TMemoryBuffer> membuf(new TMemoryBuffer()); + shared_ptr<TMemoryBuffer> membuf(new TMemoryBuffer()); { // Create a TZlibTransport object, and immediately destroy it // when it goes out of scope. @@ -341,7 +341,8 @@ void test_no_write() { do { \ ::std::ostringstream name_ss; \ name_ss << name << "-" << BOOST_STRINGIZE(_FUNC); \ - boost::function<void ()> test_func = ::apache::thrift::stdcxx::bind(_FUNC, ##__VA_ARGS__); \ + ::apache::thrift::stdcxx::function<void ()> test_func = \ + ::apache::thrift::stdcxx::bind(_FUNC, ##__VA_ARGS__); \ ::boost::unit_test::test_case* tc \ = ::boost::unit_test::make_test_case(test_func, name_ss.str(), __FILE__, __LINE__); \ (suite)->add(tc); \ @@ -369,8 +370,8 @@ void add_tests(boost::unit_test::test_suite* suite, ADD_TEST_CASE(suite, name, test_invalid_checksum, buf, buf_len); ADD_TEST_CASE(suite, name, test_write_after_flush, buf, buf_len); - boost::shared_ptr<SizeGenerator> size_32k(new ConstantSizeGenerator(1 << 15)); - boost::shared_ptr<SizeGenerator> size_lognormal(new LogNormalSizeGenerator(20, 30)); + shared_ptr<SizeGenerator> size_32k(new ConstantSizeGenerator(1 << 15)); + shared_ptr<SizeGenerator> size_lognormal(new LogNormalSizeGenerator(20, 30)); ADD_TEST_CASE(suite, name << "-constant", test_read_write_mix, buf, buf_len, size_32k, size_32k); ADD_TEST_CASE(suite, name << "-lognormal-write", @@ -400,8 +401,8 @@ void add_tests(boost::unit_test::test_suite* suite, // Because the SizeGenerator makes a copy of the random number generator, // both SizeGenerators should return the exact same set of values, since they // both start with random number generators in the same state. - boost::shared_ptr<SizeGenerator> write_size_gen(new LogNormalSizeGenerator(20, 30)); - boost::shared_ptr<SizeGenerator> read_size_gen(new LogNormalSizeGenerator(20, 30)); + shared_ptr<SizeGenerator> write_size_gen(new LogNormalSizeGenerator(20, 30)); + shared_ptr<SizeGenerator> read_size_gen(new LogNormalSizeGenerator(20, 30)); ADD_TEST_CASE(suite, name << "-lognormal-same-distribution", test_read_write_mix, diff --git a/lib/cpp/test/concurrency/RWMutexStarveTest.cpp b/lib/cpp/test/concurrency/RWMutexStarveTest.cpp index 63d780fa1..849e078bd 100644 --- a/lib/cpp/test/concurrency/RWMutexStarveTest.cpp +++ b/lib/cpp/test/concurrency/RWMutexStarveTest.cpp @@ -19,22 +19,21 @@ // This is linked into the UnitTests test executable -#include <boost/shared_ptr.hpp> #include <boost/test/unit_test.hpp> #include "thrift/concurrency/Mutex.h" #include "thrift/concurrency/PosixThreadFactory.h" +#include <thrift/stdcxx.h> -using boost::shared_ptr; +using apache::thrift::stdcxx::shared_ptr; using boost::unit_test::test_suite; using boost::unit_test::framework::master_test_suite; using namespace apache::thrift::concurrency; -using namespace std; class Locker : public Runnable { protected: - Locker(boost::shared_ptr<ReadWriteMutex> rwlock, bool writer) + Locker(shared_ptr<ReadWriteMutex> rwlock, bool writer) : rwlock_(rwlock), writer_(writer), started_(false), gotLock_(false), signaled_(false) {} public: @@ -57,7 +56,7 @@ public: void signal() { signaled_ = true; } protected: - boost::shared_ptr<ReadWriteMutex> rwlock_; + shared_ptr<ReadWriteMutex> rwlock_; bool writer_; volatile bool started_; volatile bool gotLock_; @@ -66,12 +65,12 @@ protected: class Reader : public Locker { public: - Reader(boost::shared_ptr<ReadWriteMutex> rwlock) : Locker(rwlock, false) {} + Reader(shared_ptr<ReadWriteMutex> rwlock) : Locker(rwlock, false) {} }; class Writer : public Locker { public: - Writer(boost::shared_ptr<ReadWriteMutex> rwlock) : Locker(rwlock, true) {} + Writer(shared_ptr<ReadWriteMutex> rwlock) : Locker(rwlock, true) {} }; void test_starve(PosixThreadFactory::POLICY policy) { @@ -81,15 +80,15 @@ void test_starve(PosixThreadFactory::POLICY policy) { PosixThreadFactory factory(policy); factory.setDetached(false); - boost::shared_ptr<ReadWriteMutex> rwlock(new NoStarveReadWriteMutex()); + shared_ptr<ReadWriteMutex> rwlock(new NoStarveReadWriteMutex()); - boost::shared_ptr<Reader> reader1(new Reader(rwlock)); - boost::shared_ptr<Reader> reader2(new Reader(rwlock)); - boost::shared_ptr<Writer> writer(new Writer(rwlock)); + shared_ptr<Reader> reader1(new Reader(rwlock)); + shared_ptr<Reader> reader2(new Reader(rwlock)); + shared_ptr<Writer> writer(new Writer(rwlock)); - boost::shared_ptr<Thread> treader1 = factory.newThread(reader1); - boost::shared_ptr<Thread> treader2 = factory.newThread(reader2); - boost::shared_ptr<Thread> twriter = factory.newThread(writer); + shared_ptr<Thread> treader1 = factory.newThread(reader1); + shared_ptr<Thread> treader2 = factory.newThread(reader2); + shared_ptr<Thread> twriter = factory.newThread(writer); // launch a reader and make sure he has the lock treader1->start(); diff --git a/lib/cpp/test/concurrency/ThreadFactoryTests.h b/lib/cpp/test/concurrency/ThreadFactoryTests.h index 4fc688cc5..bd6ed323d 100644 --- a/lib/cpp/test/concurrency/ThreadFactoryTests.h +++ b/lib/cpp/test/concurrency/ThreadFactoryTests.h @@ -32,7 +32,7 @@ namespace thrift { namespace concurrency { namespace test { -using boost::shared_ptr; +using stdcxx::shared_ptr; using namespace apache::thrift::concurrency; /** diff --git a/lib/cpp/test/concurrency/ThreadManagerTests.h b/lib/cpp/test/concurrency/ThreadManagerTests.h index b5925ac2f..c07a21b55 100644 --- a/lib/cpp/test/concurrency/ThreadManagerTests.h +++ b/lib/cpp/test/concurrency/ThreadManagerTests.h @@ -36,8 +36,8 @@ namespace test { using namespace apache::thrift::concurrency; -static std::deque<boost::shared_ptr<Runnable> > m_expired; -static void expiredNotifier(boost::shared_ptr<Runnable> runnable) +static std::deque<stdcxx::shared_ptr<Runnable> > m_expired; +static void expiredNotifier(stdcxx::shared_ptr<Runnable> runnable) { m_expired.push_back(runnable); } diff --git a/lib/cpp/test/processor/EventLog.cpp b/lib/cpp/test/processor/EventLog.cpp index 360307ad1..e3ddbccc4 100644 --- a/lib/cpp/test/processor/EventLog.cpp +++ b/lib/cpp/test/processor/EventLog.cpp @@ -21,7 +21,6 @@ #include <stdarg.h> #include <stdlib.h> -using namespace std; using namespace apache::thrift::concurrency; namespace { @@ -82,7 +81,7 @@ EventLog::EventLog() { void EventLog::append(EventType type, uint32_t connectionId, uint32_t callId, - const string& message) { + const std::string& message) { Synchronized s(monitor_); debug("%d <-- %u, %u, %s \"%s\"", id_, connectionId, callId, type, message.c_str()); diff --git a/lib/cpp/test/processor/Handlers.h b/lib/cpp/test/processor/Handlers.h index 041fd3d3d..ad47229ad 100644 --- a/lib/cpp/test/processor/Handlers.h +++ b/lib/cpp/test/processor/Handlers.h @@ -29,7 +29,7 @@ namespace test { class ParentHandler : virtual public ParentServiceIf { public: - ParentHandler(const boost::shared_ptr<EventLog>& log) + ParentHandler(const stdcxx::shared_ptr<EventLog>& log) : triggerMonitor(&mutex_), generation_(0), wait_(false), log_(log) {} int32_t incrementGeneration() { @@ -136,7 +136,7 @@ protected: int32_t generation_; bool wait_; std::vector<std::string> strings_; - boost::shared_ptr<EventLog> log_; + stdcxx::shared_ptr<EventLog> log_; }; #ifdef _WIN32 @@ -146,7 +146,7 @@ protected: class ChildHandler : public ParentHandler, virtual public ChildServiceIf { public: - ChildHandler(const boost::shared_ptr<EventLog>& log) : ParentHandler(log), value_(0) {} + ChildHandler(const stdcxx::shared_ptr<EventLog>& log) : ParentHandler(log), value_(0) {} int32_t setValue(const int32_t value) { concurrency::Guard g(mutex_); @@ -174,13 +174,13 @@ protected: struct ConnContext { public: - ConnContext(boost::shared_ptr<protocol::TProtocol> in, - boost::shared_ptr<protocol::TProtocol> out, + ConnContext(stdcxx::shared_ptr<protocol::TProtocol> in, + stdcxx::shared_ptr<protocol::TProtocol> out, uint32_t id) : input(in), output(out), id(id) {} - boost::shared_ptr<protocol::TProtocol> input; - boost::shared_ptr<protocol::TProtocol> output; + stdcxx::shared_ptr<protocol::TProtocol> input; + stdcxx::shared_ptr<protocol::TProtocol> output; uint32_t id; }; @@ -196,12 +196,12 @@ public: class ServerEventHandler : public server::TServerEventHandler { public: - ServerEventHandler(const boost::shared_ptr<EventLog>& log) : nextId_(1), log_(log) {} + ServerEventHandler(const stdcxx::shared_ptr<EventLog>& log) : nextId_(1), log_(log) {} virtual void preServe() {} - virtual void* createContext(boost::shared_ptr<protocol::TProtocol> input, - boost::shared_ptr<protocol::TProtocol> output) { + virtual void* createContext(stdcxx::shared_ptr<protocol::TProtocol> input, + stdcxx::shared_ptr<protocol::TProtocol> output) { ConnContext* context = new ConnContext(input, output, nextId_); ++nextId_; log_->append(EventLog::ET_CONN_CREATED, context->id, 0); @@ -209,8 +209,8 @@ public: } virtual void deleteContext(void* serverContext, - boost::shared_ptr<protocol::TProtocol> input, - boost::shared_ptr<protocol::TProtocol> output) { + stdcxx::shared_ptr<protocol::TProtocol> input, + stdcxx::shared_ptr<protocol::TProtocol> output) { ConnContext* context = reinterpret_cast<ConnContext*>(serverContext); if (input != context->input) { @@ -226,7 +226,7 @@ public: } virtual void processContext(void* serverContext, - boost::shared_ptr<transport::TTransport> transport) { + stdcxx::shared_ptr<transport::TTransport> transport) { // TODO: We currently don't test the behavior of the processContext() // calls. The various server implementations call processContext() at // slightly different times, and it is too annoying to try and account for @@ -251,12 +251,12 @@ public: protected: uint32_t nextId_; - boost::shared_ptr<EventLog> log_; + stdcxx::shared_ptr<EventLog> log_; }; class ProcessorEventHandler : public TProcessorEventHandler { public: - ProcessorEventHandler(const boost::shared_ptr<EventLog>& log) : nextId_(1), log_(log) {} + ProcessorEventHandler(const stdcxx::shared_ptr<EventLog>& log) : nextId_(1), log_(log) {} void* getContext(const char* fnName, void* serverContext) { ConnContext* connContext = reinterpret_cast<ConnContext*>(serverContext); @@ -329,7 +329,7 @@ protected: } uint32_t nextId_; - boost::shared_ptr<EventLog> log_; + stdcxx::shared_ptr<EventLog> log_; }; } } diff --git a/lib/cpp/test/processor/ProcessorTest.cpp b/lib/cpp/test/processor/ProcessorTest.cpp index 486b8cfcd..c9e186fac 100644 --- a/lib/cpp/test/processor/ProcessorTest.cpp +++ b/lib/cpp/test/processor/ProcessorTest.cpp @@ -40,15 +40,14 @@ #include "Handlers.h" #include "gen-cpp/ChildService.h" -using namespace std; -using namespace boost; using namespace apache::thrift; using namespace apache::thrift::concurrency; using namespace apache::thrift::protocol; using namespace apache::thrift::server; -using namespace apache::thrift::transport; - using namespace apache::thrift::test; +using namespace apache::thrift::transport; +using std::string; +using std::vector; /* * Traits classes that encapsulate how to create various types of servers. @@ -58,13 +57,13 @@ class TSimpleServerTraits { public: typedef TSimpleServer ServerType; - boost::shared_ptr<TSimpleServer> createServer( - const boost::shared_ptr<TProcessor>& processor, + stdcxx::shared_ptr<TSimpleServer> createServer( + const stdcxx::shared_ptr<TProcessor>& processor, uint16_t port, - const boost::shared_ptr<TTransportFactory>& transportFactory, - const boost::shared_ptr<TProtocolFactory>& protocolFactory) { - boost::shared_ptr<TServerSocket> socket(new TServerSocket(port)); - return boost::shared_ptr<TSimpleServer>( + const stdcxx::shared_ptr<TTransportFactory>& transportFactory, + const stdcxx::shared_ptr<TProtocolFactory>& protocolFactory) { + stdcxx::shared_ptr<TServerSocket> socket(new TServerSocket(port)); + return stdcxx::shared_ptr<TSimpleServer>( new TSimpleServer(processor, socket, transportFactory, protocolFactory)); } }; @@ -73,13 +72,13 @@ class TThreadedServerTraits { public: typedef TThreadedServer ServerType; - boost::shared_ptr<TThreadedServer> createServer( - const boost::shared_ptr<TProcessor>& processor, + stdcxx::shared_ptr<TThreadedServer> createServer( + const stdcxx::shared_ptr<TProcessor>& processor, uint16_t port, - const boost::shared_ptr<TTransportFactory>& transportFactory, - const boost::shared_ptr<TProtocolFactory>& protocolFactory) { - boost::shared_ptr<TServerSocket> socket(new TServerSocket(port)); - return boost::shared_ptr<TThreadedServer>( + const stdcxx::shared_ptr<TTransportFactory>& transportFactory, + const stdcxx::shared_ptr<TProtocolFactory>& protocolFactory) { + stdcxx::shared_ptr<TServerSocket> socket(new TServerSocket(port)); + return stdcxx::shared_ptr<TThreadedServer>( new TThreadedServer(processor, socket, transportFactory, protocolFactory)); } }; @@ -88,19 +87,19 @@ class TThreadPoolServerTraits { public: typedef TThreadPoolServer ServerType; - boost::shared_ptr<TThreadPoolServer> createServer( - const boost::shared_ptr<TProcessor>& processor, + stdcxx::shared_ptr<TThreadPoolServer> createServer( + const stdcxx::shared_ptr<TProcessor>& processor, uint16_t port, - const boost::shared_ptr<TTransportFactory>& transportFactory, - const boost::shared_ptr<TProtocolFactory>& protocolFactory) { - boost::shared_ptr<TServerSocket> socket(new TServerSocket(port)); + const stdcxx::shared_ptr<TTransportFactory>& transportFactory, + const stdcxx::shared_ptr<TProtocolFactory>& protocolFactory) { + stdcxx::shared_ptr<TServerSocket> socket(new TServerSocket(port)); - boost::shared_ptr<PlatformThreadFactory> threadFactory(new PlatformThreadFactory); - boost::shared_ptr<ThreadManager> threadManager = ThreadManager::newSimpleThreadManager(8); + stdcxx::shared_ptr<PlatformThreadFactory> threadFactory(new PlatformThreadFactory); + stdcxx::shared_ptr<ThreadManager> threadManager = ThreadManager::newSimpleThreadManager(8); threadManager->threadFactory(threadFactory); threadManager->start(); - return boost::shared_ptr<TThreadPoolServer>( + return stdcxx::shared_ptr<TThreadPoolServer>( new TThreadPoolServer(processor, socket, transportFactory, protocolFactory, threadManager)); } }; @@ -109,11 +108,11 @@ class TNonblockingServerTraits { public: typedef TNonblockingServer ServerType; - boost::shared_ptr<TNonblockingServer> createServer( - const boost::shared_ptr<TProcessor>& processor, + stdcxx::shared_ptr<TNonblockingServer> createServer( + const stdcxx::shared_ptr<TProcessor>& processor, uint16_t port, - const boost::shared_ptr<TTransportFactory>& transportFactory, - const boost::shared_ptr<TProtocolFactory>& protocolFactory) { + const stdcxx::shared_ptr<TTransportFactory>& transportFactory, + const stdcxx::shared_ptr<TProtocolFactory>& protocolFactory) { // TNonblockingServer automatically uses TFramedTransport. // Raise an exception if the supplied transport factory is not a // TFramedTransportFactory @@ -122,13 +121,14 @@ public: if (framedFactory == NULL) { throw TException("TNonblockingServer must use TFramedTransport"); } - boost::shared_ptr<TNonblockingServerSocket> socket(new TNonblockingServerSocket(port)); - boost::shared_ptr<PlatformThreadFactory> threadFactory(new PlatformThreadFactory); - boost::shared_ptr<ThreadManager> threadManager = ThreadManager::newSimpleThreadManager(8); + + stdcxx::shared_ptr<TNonblockingServerSocket> socket(new TNonblockingServerSocket(port)); + stdcxx::shared_ptr<PlatformThreadFactory> threadFactory(new PlatformThreadFactory); + stdcxx::shared_ptr<ThreadManager> threadManager = ThreadManager::newSimpleThreadManager(8); threadManager->threadFactory(threadFactory); threadManager->start(); - return boost::shared_ptr<TNonblockingServer>( + return stdcxx::shared_ptr<TNonblockingServer>( new TNonblockingServer(processor, protocolFactory, socket, threadManager)); } }; @@ -137,11 +137,11 @@ class TNonblockingServerNoThreadsTraits { public: typedef TNonblockingServer ServerType; - boost::shared_ptr<TNonblockingServer> createServer( - const boost::shared_ptr<TProcessor>& processor, + stdcxx::shared_ptr<TNonblockingServer> createServer( + const stdcxx::shared_ptr<TProcessor>& processor, uint16_t port, - const boost::shared_ptr<TTransportFactory>& transportFactory, - const boost::shared_ptr<TProtocolFactory>& protocolFactory) { + const stdcxx::shared_ptr<TTransportFactory>& transportFactory, + const stdcxx::shared_ptr<TProtocolFactory>& protocolFactory) { // TNonblockingServer automatically uses TFramedTransport. // Raise an exception if the supplied transport factory is not a // TFramedTransportFactory @@ -151,10 +151,10 @@ public: throw TException("TNonblockingServer must use TFramedTransport"); } - boost::shared_ptr<TNonblockingServerSocket> socket(new TNonblockingServerSocket(port)); + stdcxx::shared_ptr<TNonblockingServerSocket> socket(new TNonblockingServerSocket(port)); // Use a NULL ThreadManager - boost::shared_ptr<ThreadManager> threadManager; - return boost::shared_ptr<TNonblockingServer>( + stdcxx::shared_ptr<ThreadManager> threadManager; + return stdcxx::shared_ptr<TNonblockingServer>( new TNonblockingServer(processor, protocolFactory, socket, threadManager)); } }; @@ -244,48 +244,48 @@ public: processor_->setEventHandler(processorEventHandler_); } - boost::shared_ptr<TServer> createServer(uint16_t port) { + stdcxx::shared_ptr<TServer> createServer(uint16_t port) { ServerTraits_ serverTraits; return serverTraits.createServer(processor_, port, transportFactory_, protocolFactory_); } - boost::shared_ptr<TServerEventHandler> getServerEventHandler() { return serverEventHandler_; } + stdcxx::shared_ptr<TServerEventHandler> getServerEventHandler() { return serverEventHandler_; } void bindSuccessful(uint16_t port) { port_ = port; } uint16_t getPort() const { return port_; } - const boost::shared_ptr<EventLog>& getLog() const { return log_; } + const stdcxx::shared_ptr<EventLog>& getLog() const { return log_; } - const boost::shared_ptr<Handler>& getHandler() const { return handler_; } + const stdcxx::shared_ptr<Handler>& getHandler() const { return handler_; } - boost::shared_ptr<Client> createClient() { + stdcxx::shared_ptr<Client> createClient() { typedef typename ServiceTraits_::Protocol Protocol; - boost::shared_ptr<TSocket> socket(new TSocket("127.0.0.1", port_)); - boost::shared_ptr<Transport_> transport(new Transport_(socket)); - boost::shared_ptr<Protocol> protocol(new Protocol(transport)); + stdcxx::shared_ptr<TSocket> socket(new TSocket("127.0.0.1", port_)); + stdcxx::shared_ptr<Transport_> transport(new Transport_(socket)); + stdcxx::shared_ptr<Protocol> protocol(new Protocol(transport)); transport->open(); - boost::shared_ptr<Client> client(new Client(protocol)); + stdcxx::shared_ptr<Client> client(new Client(protocol)); return client; } private: uint16_t port_; - boost::shared_ptr<EventLog> log_; - boost::shared_ptr<Handler> handler_; - boost::shared_ptr<Processor> processor_; - boost::shared_ptr<TTransportFactory> transportFactory_; - boost::shared_ptr<TProtocolFactory> protocolFactory_; - boost::shared_ptr<TServerEventHandler> serverEventHandler_; - boost::shared_ptr<TProcessorEventHandler> processorEventHandler_; + stdcxx::shared_ptr<EventLog> log_; + stdcxx::shared_ptr<Handler> handler_; + stdcxx::shared_ptr<Processor> processor_; + stdcxx::shared_ptr<TTransportFactory> transportFactory_; + stdcxx::shared_ptr<TProtocolFactory> protocolFactory_; + stdcxx::shared_ptr<TServerEventHandler> serverEventHandler_; + stdcxx::shared_ptr<TProcessorEventHandler> processorEventHandler_; }; /** * Check that there are no more events in the log */ -void checkNoEvents(const boost::shared_ptr<EventLog>& log) { +void checkNoEvents(const stdcxx::shared_ptr<EventLog>& log) { // Wait for an event with a very short timeout period. We don't expect // anything to be present, so we will normally wait for the full timeout. // On the other hand, a non-zero timeout is nice since it does give a short @@ -299,7 +299,7 @@ void checkNoEvents(const boost::shared_ptr<EventLog>& log) { * * Returns the connection ID allocated by the server. */ -uint32_t checkNewConnEvents(const boost::shared_ptr<EventLog>& log) { +uint32_t checkNewConnEvents(const stdcxx::shared_ptr<EventLog>& log) { // Check for an ET_CONN_CREATED event Event event = log->waitForEvent(2500); BOOST_CHECK_EQUAL(EventLog::ET_CONN_CREATED, event.type); @@ -314,7 +314,7 @@ uint32_t checkNewConnEvents(const boost::shared_ptr<EventLog>& log) { /** * Check for the events that should be logged when a connection is closed. */ -void checkCloseEvents(const boost::shared_ptr<EventLog>& log, uint32_t connId) { +void checkCloseEvents(const stdcxx::shared_ptr<EventLog>& log, uint32_t connId) { // Check for an ET_CONN_DESTROYED event Event event = log->waitForEvent(); BOOST_CHECK_EQUAL(EventLog::ET_CONN_DESTROYED, event.type); @@ -332,7 +332,7 @@ void checkCloseEvents(const boost::shared_ptr<EventLog>& log, uint32_t connId) { * * Returns the call ID allocated by the server. */ -uint32_t checkCallHandlerEvents(const boost::shared_ptr<EventLog>& log, +uint32_t checkCallHandlerEvents(const stdcxx::shared_ptr<EventLog>& log, uint32_t connId, EventType callType, const string& callName) { @@ -369,7 +369,7 @@ uint32_t checkCallHandlerEvents(const boost::shared_ptr<EventLog>& log, /** * Check for the events that should be after a handler returns. */ -void checkCallPostHandlerEvents(const boost::shared_ptr<EventLog>& log, +void checkCallPostHandlerEvents(const stdcxx::shared_ptr<EventLog>& log, uint32_t connId, uint32_t callId, const string& callName) { @@ -409,7 +409,7 @@ void checkCallPostHandlerEvents(const boost::shared_ptr<EventLog>& log, * * Returns the call ID allocated by the server. */ -uint32_t checkCallEvents(const boost::shared_ptr<EventLog>& log, +uint32_t checkCallEvents(const stdcxx::shared_ptr<EventLog>& log, uint32_t connId, EventType callType, const string& callName) { @@ -424,8 +424,8 @@ uint32_t checkCallEvents(const boost::shared_ptr<EventLog>& log, */ template <typename State_> -void testParentService(const boost::shared_ptr<State_>& state) { - boost::shared_ptr<typename State_::Client> client = state->createClient(); +void testParentService(const stdcxx::shared_ptr<State_>& state) { + stdcxx::shared_ptr<typename State_::Client> client = state->createClient(); int32_t gen = client->getGeneration(); int32_t newGen = client->incrementGeneration(); @@ -446,8 +446,8 @@ void testParentService(const boost::shared_ptr<State_>& state) { } template <typename State_> -void testChildService(const boost::shared_ptr<State_>& state) { - boost::shared_ptr<typename State_::Client> client = state->createClient(); +void testChildService(const stdcxx::shared_ptr<State_>& state) { + stdcxx::shared_ptr<typename State_::Client> client = state->createClient(); // Test calling some of the parent methids via the a child client int32_t gen = client->getGeneration(); @@ -468,7 +468,7 @@ void testBasicService() { typedef ServiceState<ServerTraits, ParentServiceTraits<TemplateTraits> > State; // Start the server - boost::shared_ptr<State> state(new State); + stdcxx::shared_ptr<State> state(new State); ServerThread serverThread(state, true); testParentService(state); @@ -479,7 +479,7 @@ void testInheritedService() { typedef ServiceState<ServerTraits, ChildServiceTraits<TemplateTraits> > State; // Start the server - boost::shared_ptr<State> state(new State); + stdcxx::shared_ptr<State> state(new State); ServerThread serverThread(state, true); testParentService(state); @@ -502,10 +502,10 @@ void testEventSequencing() { TBufferedTransport> State; // Start the server - boost::shared_ptr<State> state(new State); + stdcxx::shared_ptr<State> state(new State); ServerThread serverThread(state, true); - const boost::shared_ptr<EventLog>& log = state->getLog(); + const stdcxx::shared_ptr<EventLog>& log = state->getLog(); // Make sure we're at the end of the log checkNoEvents(log); @@ -514,7 +514,7 @@ void testEventSequencing() { // Make sure createContext() is called after a connection has been // established. We open a plain socket instead of creating a client. - boost::shared_ptr<TSocket> socket(new TSocket("127.0.0.1", state->getPort())); + stdcxx::shared_ptr<TSocket> socket(new TSocket("127.0.0.1", state->getPort())); socket->open(); // Make sure the proper events occurred after a new connection @@ -592,7 +592,7 @@ void testEventSequencing() { checkNoEvents(log); // Read the response header - std::string responseName; + string responseName; int32_t responseSeqid = 0; apache::thrift::protocol::TMessageType responseType; protocol.readMessageBegin(responseName, responseType, responseSeqid); @@ -635,19 +635,19 @@ void testSeparateConnections() { typedef ServiceState<ServerTraits, ChildServiceTraits<TemplateTraits> > State; // Start the server - boost::shared_ptr<State> state(new State); + stdcxx::shared_ptr<State> state(new State); ServerThread serverThread(state, true); - const boost::shared_ptr<EventLog>& log = state->getLog(); + const stdcxx::shared_ptr<EventLog>& log = state->getLog(); // Create a client - boost::shared_ptr<typename State::Client> client1 = state->createClient(); + stdcxx::shared_ptr<typename State::Client> client1 = state->createClient(); // Make sure the expected events were logged uint32_t client1Id = checkNewConnEvents(log); // Create a second client - boost::shared_ptr<typename State::Client> client2 = state->createClient(); + stdcxx::shared_ptr<typename State::Client> client2 = state->createClient(); // Make sure the expected events were logged uint32_t client2Id = checkNewConnEvents(log); @@ -683,13 +683,13 @@ void testOnewayCall() { typedef ServiceState<ServerTraits, ChildServiceTraits<TemplateTraits> > State; // Start the server - boost::shared_ptr<State> state(new State); + stdcxx::shared_ptr<State> state(new State); ServerThread serverThread(state, true); - const boost::shared_ptr<EventLog>& log = state->getLog(); + const stdcxx::shared_ptr<EventLog>& log = state->getLog(); // Create a client - boost::shared_ptr<typename State::Client> client = state->createClient(); + stdcxx::shared_ptr<typename State::Client> client = state->createClient(); uint32_t connId = checkNewConnEvents(log); // Make a oneway call @@ -735,13 +735,13 @@ void testExpectedError() { typedef ServiceState<ServerTraits, ChildServiceTraits<TemplateTraits> > State; // Start the server - boost::shared_ptr<State> state(new State); + stdcxx::shared_ptr<State> state(new State); ServerThread serverThread(state, true); - const boost::shared_ptr<EventLog>& log = state->getLog(); + const stdcxx::shared_ptr<EventLog>& log = state->getLog(); // Create a client - boost::shared_ptr<typename State::Client> client = state->createClient(); + stdcxx::shared_ptr<typename State::Client> client = state->createClient(); uint32_t connId = checkNewConnEvents(log); // Send the exceptionWait() call @@ -768,8 +768,8 @@ void testExpectedError() { } catch (const MyError& e) { BOOST_CHECK_EQUAL(message, e.message); // Check if std::exception::what() is handled properly - size_t message_pos = std::string(e.what()).find("TException - service has thrown: MyError"); - BOOST_CHECK_NE(message_pos, std::string::npos); + size_t message_pos = string(e.what()).find("TException - service has thrown: MyError"); + BOOST_CHECK_NE(message_pos, string::npos); } // Now we should see the events for a normal call finish @@ -790,13 +790,13 @@ void testUnexpectedError() { typedef ServiceState<ServerTraits, ChildServiceTraits<TemplateTraits> > State; // Start the server - boost::shared_ptr<State> state(new State); + stdcxx::shared_ptr<State> state(new State); ServerThread serverThread(state, true); - const boost::shared_ptr<EventLog>& log = state->getLog(); + const stdcxx::shared_ptr<EventLog>& log = state->getLog(); // Create a client - boost::shared_ptr<typename State::Client> client = state->createClient(); + stdcxx::shared_ptr<typename State::Client> client = state->createClient(); uint32_t connId = checkNewConnEvents(log); // Send the unexpectedExceptionWait() call @@ -912,7 +912,7 @@ DEFINE_NOFRAME_TESTS(TSimpleServer, Untemplated) // For now, it is known not to work correctly with TProcessorEventHandler. #ifdef BOOST_TEST_DYN_LINK bool init_unit_test_suite() { - unit_test::framework::master_test_suite().p_name.value = "ProcessorTest"; + ::boost::unit_test::framework::master_test_suite().p_name.value = "ProcessorTest"; return true; } @@ -920,10 +920,10 @@ int main( int argc, char* argv[] ) { return ::boost::unit_test::unit_test_main(&init_unit_test_suite,argc,argv); } #else -unit_test::test_suite* init_unit_test_suite(int argc, char* argv[]) { +::boost::unit_test::test_suite* init_unit_test_suite(int argc, char* argv[]) { THRIFT_UNUSED_VARIABLE(argc); THRIFT_UNUSED_VARIABLE(argv); - unit_test::framework::master_test_suite().p_name.value = "ProcessorTest"; + ::boost::unit_test::framework::master_test_suite().p_name.value = "ProcessorTest"; return NULL; } #endif diff --git a/lib/cpp/test/processor/ServerThread.cpp b/lib/cpp/test/processor/ServerThread.cpp index 009c4c66f..e752d5e1d 100644 --- a/lib/cpp/test/processor/ServerThread.cpp +++ b/lib/cpp/test/processor/ServerThread.cpp @@ -130,7 +130,7 @@ void ServerThread::preServe() { serverState_->bindSuccessful(port_); // Set the real server event handler (replacing ourself) - boost::shared_ptr<server::TServerEventHandler> serverEventHandler + stdcxx::shared_ptr<server::TServerEventHandler> serverEventHandler = serverState_->getServerEventHandler(); server_->setServerEventHandler(serverEventHandler); diff --git a/lib/cpp/test/processor/ServerThread.h b/lib/cpp/test/processor/ServerThread.h index 3803e7e73..21c3b60e0 100644 --- a/lib/cpp/test/processor/ServerThread.h +++ b/lib/cpp/test/processor/ServerThread.h @@ -43,7 +43,7 @@ public: * If the server returned fails to bind to the specified port when serve() is * called on it, createServer() may be called again on a different port. */ - virtual boost::shared_ptr<server::TServer> createServer(uint16_t port) = 0; + virtual stdcxx::shared_ptr<server::TServer> createServer(uint16_t port) = 0; /** * Get the TServerEventHandler to set on the server. @@ -52,8 +52,8 @@ public: * start serving traffic. It is invoked from the server thread, rather than * the main thread. */ - virtual boost::shared_ptr<server::TServerEventHandler> getServerEventHandler() { - return boost::shared_ptr<server::TServerEventHandler>(); + virtual stdcxx::shared_ptr<server::TServerEventHandler> getServerEventHandler() { + return stdcxx::shared_ptr<server::TServerEventHandler>(); } /** @@ -70,7 +70,7 @@ public: */ class ServerThread { public: - ServerThread(const boost::shared_ptr<ServerState>& state, bool autoStart) + ServerThread(const stdcxx::shared_ptr<ServerState>& state, bool autoStart) : port_(0), running_(false), serving_(false), @@ -116,7 +116,7 @@ protected: void run(); void preServe(); - boost::shared_ptr<Helper> helper_; + stdcxx::shared_ptr<Helper> helper_; uint16_t port_; bool running_; @@ -124,9 +124,9 @@ protected: bool error_; concurrency::Monitor serverMonitor_; - boost::shared_ptr<ServerState> serverState_; - boost::shared_ptr<server::TServer> server_; - boost::shared_ptr<concurrency::Thread> thread_; + stdcxx::shared_ptr<ServerState> serverState_; + stdcxx::shared_ptr<server::TServer> server_; + stdcxx::shared_ptr<concurrency::Thread> thread_; }; } } diff --git a/lib/cpp/test/qt/TQTcpServerTest.cpp b/lib/cpp/test/qt/TQTcpServerTest.cpp index 422d771af..8a327aa24 100644 --- a/lib/cpp/test/qt/TQTcpServerTest.cpp +++ b/lib/cpp/test/qt/TQTcpServerTest.cpp @@ -8,12 +8,12 @@ #include <QThread> #ifndef Q_MOC_RUN - #include <boost/smart_ptr.hpp> + #include "thrift/stdcxx.h" #include "thrift/protocol/TBinaryProtocol.h" #include "thrift/async/TAsyncProcessor.h" #include "thrift/qt/TQTcpServer.h" #include "thrift/qt/TQIODeviceTransport.h" - + #include "gen-cpp/ParentService.h" #endif @@ -21,25 +21,25 @@ using namespace apache::thrift; struct AsyncHandler : public test::ParentServiceCobSvIf { std::vector<std::string> strings; - virtual void addString(tcxx::function<void()> cob, const std::string& s) { + virtual void addString(stdcxx::function<void()> cob, const std::string& s) { strings.push_back(s); cob(); } - virtual void getStrings(tcxx::function<void(std::vector<std::string> const& _return)> cob) { + virtual void getStrings(stdcxx::function<void(std::vector<std::string> const& _return)> cob) { cob(strings); } // Overrides not used in this test - virtual void incrementGeneration(tcxx::function<void(int32_t const& _return)> cob) {} - virtual void getGeneration(tcxx::function<void(int32_t const& _return)> cob) {} - virtual void getDataWait(tcxx::function<void(std::string const& _return)> cob, + virtual void incrementGeneration(stdcxx::function<void(int32_t const& _return)> cob) {} + virtual void getGeneration(stdcxx::function<void(int32_t const& _return)> cob) {} + virtual void getDataWait(stdcxx::function<void(std::string const& _return)> cob, const int32_t length) {} - virtual void onewayWait(tcxx::function<void()> cob) {} + virtual void onewayWait(stdcxx::function<void()> cob) {} virtual void exceptionWait( - tcxx::function<void()> cob, - tcxx::function<void(::apache::thrift::TDelayedException* _throw)> /* exn_cob */, + stdcxx::function<void()> cob, + stdcxx::function<void(::apache::thrift::TDelayedException* _throw)> /* exn_cob */, const std::string& message) {} - virtual void unexpectedExceptionWait(tcxx::function<void()> cob, const std::string& message) {} + virtual void unexpectedExceptionWait(stdcxx::function<void()> cob, const std::string& message) {} }; class TQTcpServerTest : public QObject { @@ -51,18 +51,18 @@ private slots: void test_communicate(); private: - boost::shared_ptr<QThread> serverThread; - boost::shared_ptr<async::TQTcpServer> server; - boost::shared_ptr<test::ParentServiceClient> client; + stdcxx::shared_ptr<QThread> serverThread; + stdcxx::shared_ptr<async::TQTcpServer> server; + stdcxx::shared_ptr<test::ParentServiceClient> client; }; void TQTcpServerTest::initTestCase() { // setup server - boost::shared_ptr<QTcpServer> serverSocket = boost::make_shared<QTcpServer>(); + stdcxx::shared_ptr<QTcpServer> serverSocket = stdcxx::make_shared<QTcpServer>(); server.reset(new async::TQTcpServer(serverSocket, - boost::make_shared<test::ParentServiceAsyncProcessor>( - boost::make_shared<AsyncHandler>()), - boost::make_shared<protocol::TBinaryProtocolFactory>())); + stdcxx::make_shared<test::ParentServiceAsyncProcessor>( + stdcxx::make_shared<AsyncHandler>()), + stdcxx::make_shared<protocol::TBinaryProtocolFactory>())); QVERIFY(serverSocket->listen(QHostAddress::LocalHost)); int port = serverSocket->serverPort(); QVERIFY(port > 0); @@ -74,9 +74,9 @@ void TQTcpServerTest::initTestCase() { serverThread->start(); // setup client - boost::shared_ptr<QTcpSocket> socket = boost::make_shared<QTcpSocket>(); - client.reset(new test::ParentServiceClient(boost::make_shared<protocol::TBinaryProtocol>( - boost::make_shared<transport::TQIODeviceTransport>(socket)))); + stdcxx::shared_ptr<QTcpSocket> socket = stdcxx::make_shared<QTcpSocket>(); + client.reset(new test::ParentServiceClient(stdcxx::make_shared<protocol::TBinaryProtocol>( + stdcxx::make_shared<transport::TQIODeviceTransport>(socket)))); socket->connectToHost(QHostAddress::LocalHost, port); QVERIFY(socket->waitForConnected()); } diff --git a/test/cpp/src/StressTest.cpp b/test/cpp/src/StressTest.cpp index 9371bce78..5ff5e44f9 100644 --- a/test/cpp/src/StressTest.cpp +++ b/test/cpp/src/StressTest.cpp @@ -31,6 +31,7 @@ #include <thrift/transport/TTransportUtils.h> #include <thrift/transport/TFileTransport.h> #include <thrift/TLogging.h> +#include <thrift/stdcxx.h> #include "Service.h" #include <iostream> @@ -107,8 +108,8 @@ enum TransportOpenCloseBehavior { }; class ClientThread : public Runnable { public: - ClientThread(boost::shared_ptr<TTransport> transport, - boost::shared_ptr<ServiceIf> client, + ClientThread(stdcxx::shared_ptr<TTransport> transport, + stdcxx::shared_ptr<ServiceIf> client, Monitor& monitor, size_t& workerCount, size_t loopCount, @@ -224,8 +225,8 @@ public: } } - boost::shared_ptr<TTransport> _transport; - boost::shared_ptr<ServiceIf> _client; + stdcxx::shared_ptr<TTransport> _transport; + stdcxx::shared_ptr<ServiceIf> _client; Monitor& _monitor; size_t& _workerCount; size_t _loopCount; @@ -285,14 +286,14 @@ int main(int argc, char** argv) { "server only. Default is " << clientCount << endl << "\thelp Prints this help text." << endl << "\tcall Service method to call. Default is " << callName << endl - << "\tloop The number of remote thrift calls each client makes. Default is " << loopCount << endl + << "\tloop The number of remote thrift calls each client makes. Default is " << loopCount << endl << "\tport The port the server and clients should bind to " "for thrift network connections. Default is " << port << endl - << "\tserver Run the Thrift server in this process. Default is " << runServer << endl + << "\tserver Run the Thrift server in this process. Default is " << runServer << endl << "\tserver-type Type of server, \"simple\" or \"thread-pool\". Default is " << serverType << endl << "\tprotocol-type Type of protocol, \"binary\", \"ascii\", or \"xml\". Default is " << protocolType << endl - << "\tlog-request Log all request to ./requestlog.tlog. Default is " << logRequests << endl - << "\treplay-request Replay requests from log file (./requestlog.tlog) Default is " << replayRequests << endl + << "\tlog-request Log all request to ./requestlog.tlog. Default is " << logRequests << endl + << "\treplay-request Replay requests from log file (./requestlog.tlog) Default is " << replayRequests << endl << "\tworkers Number of thread pools workers. Only valid " "for thread-pool server type. Default is " << workerCount << endl << "\tclient-type Type of client, \"regular\" or \"concurrent\". Default is " << clientType << endl @@ -390,24 +391,24 @@ int main(int argc, char** argv) { cerr << usage.str(); } - boost::shared_ptr<PlatformThreadFactory> threadFactory - = boost::shared_ptr<PlatformThreadFactory>(new PlatformThreadFactory()); + stdcxx::shared_ptr<PlatformThreadFactory> threadFactory + = stdcxx::shared_ptr<PlatformThreadFactory>(new PlatformThreadFactory()); // Dispatcher - boost::shared_ptr<Server> serviceHandler(new Server()); + stdcxx::shared_ptr<Server> serviceHandler(new Server()); if (replayRequests) { - boost::shared_ptr<Server> serviceHandler(new Server()); - boost::shared_ptr<ServiceProcessor> serviceProcessor(new ServiceProcessor(serviceHandler)); + stdcxx::shared_ptr<Server> serviceHandler(new Server()); + stdcxx::shared_ptr<ServiceProcessor> serviceProcessor(new ServiceProcessor(serviceHandler)); // Transports - boost::shared_ptr<TFileTransport> fileTransport(new TFileTransport(requestLogPath)); + stdcxx::shared_ptr<TFileTransport> fileTransport(new TFileTransport(requestLogPath)); fileTransport->setChunkSize(2 * 1024 * 1024); fileTransport->setMaxEventSize(1024 * 16); fileTransport->seekToEnd(); // Protocol Factory - boost::shared_ptr<TProtocolFactory> protocolFactory(new TBinaryProtocolFactory()); + stdcxx::shared_ptr<TProtocolFactory> protocolFactory(new TBinaryProtocolFactory()); TFileProcessor fileProcessor(serviceProcessor, protocolFactory, fileTransport); @@ -417,28 +418,28 @@ int main(int argc, char** argv) { if (runServer) { - boost::shared_ptr<ServiceProcessor> serviceProcessor(new ServiceProcessor(serviceHandler)); + stdcxx::shared_ptr<ServiceProcessor> serviceProcessor(new ServiceProcessor(serviceHandler)); // Transport - boost::shared_ptr<TServerSocket> serverSocket(new TServerSocket(port)); + stdcxx::shared_ptr<TServerSocket> serverSocket(new TServerSocket(port)); // Transport Factory - boost::shared_ptr<TTransportFactory> transportFactory(new TBufferedTransportFactory()); + stdcxx::shared_ptr<TTransportFactory> transportFactory(new TBufferedTransportFactory()); // Protocol Factory - boost::shared_ptr<TProtocolFactory> protocolFactory(new TBinaryProtocolFactory()); + stdcxx::shared_ptr<TProtocolFactory> protocolFactory(new TBinaryProtocolFactory()); if (logRequests) { // initialize the log file - boost::shared_ptr<TFileTransport> fileTransport(new TFileTransport(requestLogPath)); + stdcxx::shared_ptr<TFileTransport> fileTransport(new TFileTransport(requestLogPath)); fileTransport->setChunkSize(2 * 1024 * 1024); fileTransport->setMaxEventSize(1024 * 16); transportFactory - = boost::shared_ptr<TTransportFactory>(new TPipedTransportFactory(fileTransport)); + = stdcxx::shared_ptr<TTransportFactory>(new TPipedTransportFactory(fileTransport)); } - boost::shared_ptr<TServer> server; + stdcxx::shared_ptr<TServer> server; if (serverType == "simple") { @@ -452,7 +453,7 @@ int main(int argc, char** argv) { } else if (serverType == "thread-pool") { - boost::shared_ptr<ThreadManager> threadManager + stdcxx::shared_ptr<ThreadManager> threadManager = ThreadManager::newSimpleThreadManager(workerCount); threadManager->threadFactory(threadFactory); @@ -464,9 +465,9 @@ int main(int argc, char** argv) { threadManager)); } - boost::shared_ptr<TStartObserver> observer(new TStartObserver); + stdcxx::shared_ptr<TStartObserver> observer(new TStartObserver); server->setServerEventHandler(observer); - boost::shared_ptr<Thread> serverThread = threadFactory->newThread(server); + stdcxx::shared_ptr<Thread> serverThread = threadFactory->newThread(server); cerr << "Starting the server on port " << port << endl; @@ -485,7 +486,7 @@ int main(int argc, char** argv) { size_t threadCount = 0; - set<boost::shared_ptr<Thread> > clientThreads; + set<stdcxx::shared_ptr<Thread> > clientThreads; if (callName == "echoVoid") { loopType = T_VOID; @@ -504,28 +505,28 @@ int main(int argc, char** argv) { if(clientType == "regular") { for (size_t ix = 0; ix < clientCount; ix++) { - boost::shared_ptr<TSocket> socket(new TSocket("127.0.0.1", port)); - boost::shared_ptr<TBufferedTransport> bufferedSocket(new TBufferedTransport(socket, 2048)); - boost::shared_ptr<TProtocol> protocol(new TBinaryProtocol(bufferedSocket)); - boost::shared_ptr<ServiceClient> serviceClient(new ServiceClient(protocol)); + stdcxx::shared_ptr<TSocket> socket(new TSocket("127.0.0.1", port)); + stdcxx::shared_ptr<TBufferedTransport> bufferedSocket(new TBufferedTransport(socket, 2048)); + stdcxx::shared_ptr<TProtocol> protocol(new TBinaryProtocol(bufferedSocket)); + stdcxx::shared_ptr<ServiceClient> serviceClient(new ServiceClient(protocol)); - clientThreads.insert(threadFactory->newThread(boost::shared_ptr<ClientThread>( + clientThreads.insert(threadFactory->newThread(stdcxx::shared_ptr<ClientThread>( new ClientThread(socket, serviceClient, monitor, threadCount, loopCount, loopType, OpenAndCloseTransportInThread)))); } } else if(clientType == "concurrent") { - boost::shared_ptr<TSocket> socket(new TSocket("127.0.0.1", port)); - boost::shared_ptr<TBufferedTransport> bufferedSocket(new TBufferedTransport(socket, 2048)); - boost::shared_ptr<TProtocol> protocol(new TBinaryProtocol(bufferedSocket)); - //boost::shared_ptr<ServiceClient> serviceClient(new ServiceClient(protocol)); - boost::shared_ptr<ServiceConcurrentClient> serviceClient(new ServiceConcurrentClient(protocol)); + stdcxx::shared_ptr<TSocket> socket(new TSocket("127.0.0.1", port)); + stdcxx::shared_ptr<TBufferedTransport> bufferedSocket(new TBufferedTransport(socket, 2048)); + stdcxx::shared_ptr<TProtocol> protocol(new TBinaryProtocol(bufferedSocket)); + //stdcxx::shared_ptr<ServiceClient> serviceClient(new ServiceClient(protocol)); + stdcxx::shared_ptr<ServiceConcurrentClient> serviceClient(new ServiceConcurrentClient(protocol)); socket->open(); for (size_t ix = 0; ix < clientCount; ix++) { - clientThreads.insert(threadFactory->newThread(boost::shared_ptr<ClientThread>( + clientThreads.insert(threadFactory->newThread(stdcxx::shared_ptr<ClientThread>( new ClientThread(socket, serviceClient, monitor, threadCount, loopCount, loopType, DontOpenAndCloseTransportInThread)))); } } - for (std::set<boost::shared_ptr<Thread> >::const_iterator thread = clientThreads.begin(); + for (std::set<stdcxx::shared_ptr<Thread> >::const_iterator thread = clientThreads.begin(); thread != clientThreads.end(); thread++) { (*thread)->start(); @@ -558,12 +559,12 @@ int main(int argc, char** argv) { int64_t minTime = 9223372036854775807LL; int64_t maxTime = 0; - for (set<boost::shared_ptr<Thread> >::iterator ix = clientThreads.begin(); + for (set<stdcxx::shared_ptr<Thread> >::iterator ix = clientThreads.begin(); ix != clientThreads.end(); ix++) { - boost::shared_ptr<ClientThread> client - = boost::dynamic_pointer_cast<ClientThread>((*ix)->runnable()); + stdcxx::shared_ptr<ClientThread> client + = stdcxx::dynamic_pointer_cast<ClientThread>((*ix)->runnable()); int64_t delta = client->_endTime - client->_startTime; diff --git a/test/cpp/src/StressTestNonBlocking.cpp b/test/cpp/src/StressTestNonBlocking.cpp index 1ebb9e0ca..e68988f41 100644 --- a/test/cpp/src/StressTestNonBlocking.cpp +++ b/test/cpp/src/StressTestNonBlocking.cpp @@ -33,11 +33,10 @@ #include <thrift/transport/TTransportUtils.h> #include <thrift/transport/TFileTransport.h> #include <thrift/TLogging.h> +#include <thrift/stdcxx.h> #include "Service.h" -#include <boost/shared_ptr.hpp> - #include <iostream> #include <set> #include <stdexcept> @@ -110,8 +109,8 @@ private: class ClientThread : public Runnable { public: - ClientThread(boost::shared_ptr<TTransport> transport, - boost::shared_ptr<ServiceClient> client, + ClientThread(stdcxx::shared_ptr<TTransport> transport, + stdcxx::shared_ptr<ServiceClient> client, Monitor& monitor, size_t& workerCount, size_t loopCount, @@ -222,8 +221,8 @@ public: } } - boost::shared_ptr<TTransport> _transport; - boost::shared_ptr<ServiceClient> _client; + stdcxx::shared_ptr<TTransport> _transport; + stdcxx::shared_ptr<ServiceClient> _client; Monitor& _monitor; size_t& _workerCount; size_t _loopCount; @@ -345,24 +344,24 @@ int main(int argc, char** argv) { cerr << usage.str(); } - boost::shared_ptr<PlatformThreadFactory> threadFactory - = boost::shared_ptr<PlatformThreadFactory>(new PlatformThreadFactory()); + stdcxx::shared_ptr<PlatformThreadFactory> threadFactory + = stdcxx::shared_ptr<PlatformThreadFactory>(new PlatformThreadFactory()); // Dispatcher - boost::shared_ptr<Server> serviceHandler(new Server()); + stdcxx::shared_ptr<Server> serviceHandler(new Server()); if (replayRequests) { - boost::shared_ptr<Server> serviceHandler(new Server()); - boost::shared_ptr<ServiceProcessor> serviceProcessor(new ServiceProcessor(serviceHandler)); + stdcxx::shared_ptr<Server> serviceHandler(new Server()); + stdcxx::shared_ptr<ServiceProcessor> serviceProcessor(new ServiceProcessor(serviceHandler)); // Transports - boost::shared_ptr<TFileTransport> fileTransport(new TFileTransport(requestLogPath)); + stdcxx::shared_ptr<TFileTransport> fileTransport(new TFileTransport(requestLogPath)); fileTransport->setChunkSize(2 * 1024 * 1024); fileTransport->setMaxEventSize(1024 * 16); fileTransport->seekToEnd(); // Protocol Factory - boost::shared_ptr<TProtocolFactory> protocolFactory(new TBinaryProtocolFactory()); + stdcxx::shared_ptr<TProtocolFactory> protocolFactory(new TBinaryProtocolFactory()); TFileProcessor fileProcessor(serviceProcessor, protocolFactory, fileTransport); @@ -372,48 +371,50 @@ int main(int argc, char** argv) { if (runServer) { - boost::shared_ptr<ServiceProcessor> serviceProcessor(new ServiceProcessor(serviceHandler)); + stdcxx::shared_ptr<ServiceProcessor> serviceProcessor(new ServiceProcessor(serviceHandler)); // Protocol Factory - boost::shared_ptr<TProtocolFactory> protocolFactory(new TBinaryProtocolFactory()); + stdcxx::shared_ptr<TProtocolFactory> protocolFactory(new TBinaryProtocolFactory()); // Transport Factory - boost::shared_ptr<TTransportFactory> transportFactory; + stdcxx::shared_ptr<TTransportFactory> transportFactory; if (logRequests) { // initialize the log file - boost::shared_ptr<TFileTransport> fileTransport(new TFileTransport(requestLogPath)); + stdcxx::shared_ptr<TFileTransport> fileTransport(new TFileTransport(requestLogPath)); fileTransport->setChunkSize(2 * 1024 * 1024); fileTransport->setMaxEventSize(1024 * 16); transportFactory - = boost::shared_ptr<TTransportFactory>(new TPipedTransportFactory(fileTransport)); + = stdcxx::shared_ptr<TTransportFactory>(new TPipedTransportFactory(fileTransport)); } - boost::shared_ptr<Thread> serverThread; - boost::shared_ptr<Thread> serverThread2; - boost::shared_ptr<transport::TNonblockingServerSocket> nbSocket1, nbSocket2; + stdcxx::shared_ptr<Thread> serverThread; + stdcxx::shared_ptr<Thread> serverThread2; + stdcxx::shared_ptr<transport::TNonblockingServerSocket> nbSocket1; + stdcxx::shared_ptr<transport::TNonblockingServerSocket> nbSocket2; if (serverType == "simple") { + nbSocket1.reset(new transport::TNonblockingServerSocket(port)); - serverThread = threadFactory->newThread(boost::shared_ptr<TServer>( + serverThread = threadFactory->newThread(stdcxx::shared_ptr<TServer>( new TNonblockingServer(serviceProcessor, protocolFactory, nbSocket1))); nbSocket2.reset(new transport::TNonblockingServerSocket(port + 1)); - serverThread2 = threadFactory->newThread(boost::shared_ptr<TServer>( + serverThread2 = threadFactory->newThread(stdcxx::shared_ptr<TServer>( new TNonblockingServer(serviceProcessor, protocolFactory, nbSocket2))); } else if (serverType == "thread-pool") { - boost::shared_ptr<ThreadManager> threadManager + stdcxx::shared_ptr<ThreadManager> threadManager = ThreadManager::newSimpleThreadManager(workerCount); threadManager->threadFactory(threadFactory); threadManager->start(); nbSocket1.reset(new transport::TNonblockingServerSocket(port)); - serverThread = threadFactory->newThread(boost::shared_ptr<TServer>( + serverThread = threadFactory->newThread(stdcxx::shared_ptr<TServer>( new TNonblockingServer(serviceProcessor, protocolFactory, nbSocket1, threadManager))); nbSocket2.reset(new transport::TNonblockingServerSocket(port + 1)); - serverThread2 = threadFactory->newThread(boost::shared_ptr<TServer>( + serverThread2 = threadFactory->newThread(stdcxx::shared_ptr<TServer>( new TNonblockingServer(serviceProcessor, protocolFactory, nbSocket2, threadManager))); } @@ -436,7 +437,7 @@ int main(int argc, char** argv) { size_t threadCount = 0; - set<boost::shared_ptr<Thread> > clientThreads; + set<stdcxx::shared_ptr<Thread> > clientThreads; if (callName == "echoVoid") { loopType = T_VOID; @@ -454,16 +455,16 @@ int main(int argc, char** argv) { for (uint32_t ix = 0; ix < clientCount; ix++) { - boost::shared_ptr<TSocket> socket(new TSocket("127.0.0.1", port + (ix % 2))); - boost::shared_ptr<TFramedTransport> framedSocket(new TFramedTransport(socket)); - boost::shared_ptr<TProtocol> protocol(new TBinaryProtocol(framedSocket)); - boost::shared_ptr<ServiceClient> serviceClient(new ServiceClient(protocol)); + stdcxx::shared_ptr<TSocket> socket(new TSocket("127.0.0.1", port + (ix % 2))); + stdcxx::shared_ptr<TFramedTransport> framedSocket(new TFramedTransport(socket)); + stdcxx::shared_ptr<TProtocol> protocol(new TBinaryProtocol(framedSocket)); + stdcxx::shared_ptr<ServiceClient> serviceClient(new ServiceClient(protocol)); - clientThreads.insert(threadFactory->newThread(boost::shared_ptr<ClientThread>( + clientThreads.insert(threadFactory->newThread(stdcxx::shared_ptr<ClientThread>( new ClientThread(socket, serviceClient, monitor, threadCount, loopCount, loopType)))); } - for (std::set<boost::shared_ptr<Thread> >::const_iterator thread = clientThreads.begin(); + for (std::set<stdcxx::shared_ptr<Thread> >::const_iterator thread = clientThreads.begin(); thread != clientThreads.end(); thread++) { (*thread)->start(); @@ -496,12 +497,12 @@ int main(int argc, char** argv) { int64_t minTime = 9223372036854775807LL; int64_t maxTime = 0; - for (set<boost::shared_ptr<Thread> >::iterator ix = clientThreads.begin(); + for (set<stdcxx::shared_ptr<Thread> >::iterator ix = clientThreads.begin(); ix != clientThreads.end(); ix++) { - boost::shared_ptr<ClientThread> client - = boost::dynamic_pointer_cast<ClientThread>((*ix)->runnable()); + stdcxx::shared_ptr<ClientThread> client + = stdcxx::dynamic_pointer_cast<ClientThread>((*ix)->runnable()); int64_t delta = client->_endTime - client->_startTime; diff --git a/test/cpp/src/TestClient.cpp b/test/cpp/src/TestClient.cpp index 6ecf5404d..6b2e7314d 100644 --- a/test/cpp/src/TestClient.cpp +++ b/test/cpp/src/TestClient.cpp @@ -40,10 +40,9 @@ #include <inttypes.h> #endif -#include <boost/shared_ptr.hpp> #include <boost/program_options.hpp> #include <boost/filesystem.hpp> -#include <thrift/cxxfunctional.h> +#include <thrift/stdcxx.h> #if _WIN32 #include <thrift/windows/TWinsockSingleton.h> #endif @@ -52,10 +51,10 @@ using namespace std; using namespace apache::thrift; +using namespace apache::thrift::async; using namespace apache::thrift::protocol; using namespace apache::thrift::transport; using namespace thrift::test; -using namespace apache::thrift::async; // Current time, microseconds since the epoch uint64_t now() { @@ -94,10 +93,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(tcxx::bind(testString_clientReturn, + client->testString(stdcxx::bind(testString_clientReturn, base, testNr, - tcxx::placeholders::_1), + stdcxx::placeholders::_1), os.str()); } } catch (TException& exn) { @@ -229,17 +228,17 @@ int main(int argc, char** argv) { } // THRIFT-4164: The factory MUST outlive any sockets it creates for correct behavior! - boost::shared_ptr<TSSLSocketFactory> factory; - boost::shared_ptr<TSocket> socket; - boost::shared_ptr<TTransport> transport; - boost::shared_ptr<TProtocol> protocol; + stdcxx::shared_ptr<TSSLSocketFactory> factory; + stdcxx::shared_ptr<TSocket> socket; + stdcxx::shared_ptr<TTransport> transport; + stdcxx::shared_ptr<TProtocol> protocol; if (ssl) { cout << "Client Certificate File: " << certPath << endl; cout << "Client Key File: " << keyPath << endl; cout << "CA File: " << caPath << endl; - factory = boost::shared_ptr<TSSLSocketFactory>(new TSSLSocketFactory()); + factory = stdcxx::shared_ptr<TSSLSocketFactory>(new TSSLSocketFactory()); factory->ciphers("ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH"); factory->loadTrustedCertificates(caPath.c_str()); factory->loadCertificate(certPath.c_str()); @@ -251,38 +250,38 @@ int main(int argc, char** argv) { if (abstract_namespace) { std::string abstract_socket("\0", 1); abstract_socket += domain_socket; - socket = boost::shared_ptr<TSocket>(new TSocket(abstract_socket)); + socket = stdcxx::shared_ptr<TSocket>(new TSocket(abstract_socket)); } else { - socket = boost::shared_ptr<TSocket>(new TSocket(domain_socket)); + socket = stdcxx::shared_ptr<TSocket>(new TSocket(domain_socket)); } port = 0; } else { - socket = boost::shared_ptr<TSocket>(new TSocket(host, port)); + socket = stdcxx::shared_ptr<TSocket>(new TSocket(host, port)); } } if (transport_type.compare("http") == 0) { - boost::shared_ptr<TTransport> httpSocket(new THttpClient(socket, host, "/service")); + stdcxx::shared_ptr<TTransport> httpSocket(new THttpClient(socket, host, "/service")); transport = httpSocket; } else if (transport_type.compare("framed") == 0) { - boost::shared_ptr<TFramedTransport> framedSocket(new TFramedTransport(socket)); + stdcxx::shared_ptr<TFramedTransport> framedSocket(new TFramedTransport(socket)); transport = framedSocket; } else { - boost::shared_ptr<TBufferedTransport> bufferedSocket(new TBufferedTransport(socket)); + stdcxx::shared_ptr<TBufferedTransport> bufferedSocket(new TBufferedTransport(socket)); transport = bufferedSocket; } if (protocol_type.compare("json") == 0) { - boost::shared_ptr<TProtocol> jsonProtocol(new TJSONProtocol(transport)); + stdcxx::shared_ptr<TProtocol> jsonProtocol(new TJSONProtocol(transport)); protocol = jsonProtocol; } else if (protocol_type.compare("compact") == 0) { - boost::shared_ptr<TProtocol> compactProtocol(new TCompactProtocol(transport)); + stdcxx::shared_ptr<TProtocol> compactProtocol(new TCompactProtocol(transport)); protocol = compactProtocol; } else if (protocol_type == "header") { - boost::shared_ptr<TProtocol> headerProtocol(new THeaderProtocol(transport)); + stdcxx::shared_ptr<TProtocol> headerProtocol(new THeaderProtocol(transport)); protocol = headerProtocol; } else { - boost::shared_ptr<TBinaryProtocol> binaryProtocol(new TBinaryProtocol(transport)); + stdcxx::shared_ptr<TBinaryProtocol> binaryProtocol(new TBinaryProtocol(transport)); protocol = binaryProtocol; } @@ -305,14 +304,14 @@ int main(int argc, char** argv) { cout << "Libevent Features: 0x" << hex << event_base_get_features(base) << endl; #endif - boost::shared_ptr<TProtocolFactory> protocolFactory(new TBinaryProtocolFactory()); + stdcxx::shared_ptr<TProtocolFactory> protocolFactory(new TBinaryProtocolFactory()); - boost::shared_ptr<TAsyncChannel> channel( + stdcxx::shared_ptr<TAsyncChannel> channel( new TEvhttpClientChannel(host.c_str(), "/", host.c_str(), port, base)); ThriftTestCobClient* client = new ThriftTestCobClient(channel, protocolFactory.get()); - client->testVoid(tcxx::bind(testVoid_clientReturn, + client->testVoid(stdcxx::bind(testVoid_clientReturn, base, - tcxx::placeholders::_1)); + stdcxx::placeholders::_1)); event_base_loop(base, 0); return 0; diff --git a/test/cpp/src/TestServer.cpp b/test/cpp/src/TestServer.cpp index 2b58f8ace..37d0eb600 100644 --- a/test/cpp/src/TestServer.cpp +++ b/test/cpp/src/TestServer.cpp @@ -52,7 +52,7 @@ #include <boost/program_options.hpp> #include <boost/filesystem.hpp> -#include <thrift/cxxfunctional.h> +#include <thrift/stdcxx.h> #include <signal.h> #if _WIN32 @@ -62,11 +62,11 @@ using namespace std; using namespace apache::thrift; +using namespace apache::thrift::async; using namespace apache::thrift::concurrency; using namespace apache::thrift::protocol; using namespace apache::thrift::transport; using namespace apache::thrift::server; -using namespace apache::thrift::async; using namespace thrift::test; @@ -371,66 +371,66 @@ class TestProcessorEventHandler : public TProcessorEventHandler { class TestHandlerAsync : public ThriftTestCobSvIf { public: - TestHandlerAsync(boost::shared_ptr<TestHandler>& handler) : _delegate(handler) {} + TestHandlerAsync(stdcxx::shared_ptr<TestHandler>& handler) : _delegate(handler) {} virtual ~TestHandlerAsync() {} - virtual void testVoid(tcxx::function<void()> cob) { + virtual void testVoid(stdcxx::function<void()> cob) { _delegate->testVoid(); cob(); } - virtual void testString(tcxx::function<void(std::string const& _return)> cob, + virtual void testString(stdcxx::function<void(std::string const& _return)> cob, const std::string& thing) { std::string res; _delegate->testString(res, thing); cob(res); } - virtual void testBool(tcxx::function<void(bool const& _return)> cob, const bool thing) { + virtual void testBool(stdcxx::function<void(bool const& _return)> cob, const bool thing) { bool res = _delegate->testBool(thing); cob(res); } - virtual void testByte(tcxx::function<void(int8_t const& _return)> cob, const int8_t thing) { + virtual void testByte(stdcxx::function<void(int8_t const& _return)> cob, const int8_t thing) { int8_t res = _delegate->testByte(thing); cob(res); } - virtual void testI32(tcxx::function<void(int32_t const& _return)> cob, const int32_t thing) { + virtual void testI32(stdcxx::function<void(int32_t const& _return)> cob, const int32_t thing) { int32_t res = _delegate->testI32(thing); cob(res); } - virtual void testI64(tcxx::function<void(int64_t const& _return)> cob, const int64_t thing) { + virtual void testI64(stdcxx::function<void(int64_t const& _return)> cob, const int64_t thing) { int64_t res = _delegate->testI64(thing); cob(res); } - virtual void testDouble(tcxx::function<void(double const& _return)> cob, const double thing) { + virtual void testDouble(stdcxx::function<void(double const& _return)> cob, const double thing) { double res = _delegate->testDouble(thing); cob(res); } - virtual void testBinary(tcxx::function<void(std::string const& _return)> cob, + virtual void testBinary(stdcxx::function<void(std::string const& _return)> cob, const std::string& thing) { std::string res; _delegate->testBinary(res, thing); cob(res); } - virtual void testStruct(tcxx::function<void(Xtruct const& _return)> cob, const Xtruct& thing) { + virtual void testStruct(stdcxx::function<void(Xtruct const& _return)> cob, const Xtruct& thing) { Xtruct res; _delegate->testStruct(res, thing); cob(res); } - virtual void testNest(tcxx::function<void(Xtruct2 const& _return)> cob, const Xtruct2& thing) { + virtual void testNest(stdcxx::function<void(Xtruct2 const& _return)> cob, const Xtruct2& thing) { Xtruct2 res; _delegate->testNest(res, thing); cob(res); } - virtual void testMap(tcxx::function<void(std::map<int32_t, int32_t> const& _return)> cob, + virtual void testMap(stdcxx::function<void(std::map<int32_t, int32_t> const& _return)> cob, const std::map<int32_t, int32_t>& thing) { std::map<int32_t, int32_t> res; _delegate->testMap(res, thing); @@ -438,40 +438,40 @@ public: } virtual void testStringMap( - tcxx::function<void(std::map<std::string, std::string> const& _return)> cob, + stdcxx::function<void(std::map<std::string, std::string> const& _return)> cob, const std::map<std::string, std::string>& thing) { std::map<std::string, std::string> res; _delegate->testStringMap(res, thing); cob(res); } - virtual void testSet(tcxx::function<void(std::set<int32_t> const& _return)> cob, + virtual void testSet(stdcxx::function<void(std::set<int32_t> const& _return)> cob, const std::set<int32_t>& thing) { std::set<int32_t> res; _delegate->testSet(res, thing); cob(res); } - virtual void testList(tcxx::function<void(std::vector<int32_t> const& _return)> cob, + virtual void testList(stdcxx::function<void(std::vector<int32_t> const& _return)> cob, const std::vector<int32_t>& thing) { std::vector<int32_t> res; _delegate->testList(res, thing); cob(res); } - virtual void testEnum(tcxx::function<void(Numberz::type const& _return)> cob, + virtual void testEnum(stdcxx::function<void(Numberz::type const& _return)> cob, const Numberz::type thing) { Numberz::type res = _delegate->testEnum(thing); cob(res); } - virtual void testTypedef(tcxx::function<void(UserId const& _return)> cob, const UserId thing) { + virtual void testTypedef(stdcxx::function<void(UserId const& _return)> cob, const UserId thing) { UserId res = _delegate->testTypedef(thing); cob(res); } virtual void testMapMap( - tcxx::function<void(std::map<int32_t, std::map<int32_t, int32_t> > const& _return)> cob, + stdcxx::function<void(std::map<int32_t, std::map<int32_t, int32_t> > const& _return)> cob, const int32_t hello) { std::map<int32_t, std::map<int32_t, int32_t> > res; _delegate->testMapMap(res, hello); @@ -479,14 +479,14 @@ public: } virtual void testInsanity( - tcxx::function<void(std::map<UserId, std::map<Numberz::type, Insanity> > const& _return)> cob, + stdcxx::function<void(std::map<UserId, std::map<Numberz::type, Insanity> > const& _return)> cob, const Insanity& argument) { std::map<UserId, std::map<Numberz::type, Insanity> > res; _delegate->testInsanity(res, argument); cob(res); } - virtual void testMulti(tcxx::function<void(Xtruct const& _return)> cob, + virtual void testMulti(stdcxx::function<void(Xtruct const& _return)> cob, const int8_t arg0, const int32_t arg1, const int64_t arg2, @@ -499,8 +499,8 @@ public: } virtual void testException( - tcxx::function<void()> cob, - tcxx::function<void(::apache::thrift::TDelayedException* _throw)> exn_cob, + stdcxx::function<void()> cob, + stdcxx::function<void(::apache::thrift::TDelayedException* _throw)> exn_cob, const std::string& arg) { try { _delegate->testException(arg); @@ -512,8 +512,8 @@ public: } virtual void testMultiException( - tcxx::function<void(Xtruct const& _return)> cob, - tcxx::function<void(::apache::thrift::TDelayedException* _throw)> exn_cob, + stdcxx::function<void(Xtruct const& _return)> cob, + stdcxx::function<void(::apache::thrift::TDelayedException* _throw)> exn_cob, const std::string& arg0, const std::string& arg1) { Xtruct res; @@ -526,13 +526,13 @@ public: cob(res); } - virtual void testOneway(tcxx::function<void()> cob, const int32_t secondsToSleep) { + virtual void testOneway(stdcxx::function<void()> cob, const int32_t secondsToSleep) { _delegate->testOneway(secondsToSleep); cob(); } protected: - boost::shared_ptr<TestHandler> _delegate; + stdcxx::shared_ptr<TestHandler> _delegate; }; namespace po = boost::program_options; @@ -626,9 +626,9 @@ int main(int argc, char** argv) { } // Dispatcher - boost::shared_ptr<TProtocolFactory> protocolFactory; + stdcxx::shared_ptr<TProtocolFactory> protocolFactory; if (protocol_type == "json") { - boost::shared_ptr<TProtocolFactory> jsonProtocolFactory(new TJSONProtocolFactory()); + stdcxx::shared_ptr<TProtocolFactory> jsonProtocolFactory(new TJSONProtocolFactory()); protocolFactory = jsonProtocolFactory; } else if (protocol_type == "compact") { TCompactProtocolFactoryT<TBufferBase> *compactProtocolFactory = new TCompactProtocolFactoryT<TBufferBase>(); @@ -636,7 +636,7 @@ int main(int argc, char** argv) { compactProtocolFactory->setStringSizeLimit(string_limit); protocolFactory.reset(compactProtocolFactory); } else if (protocol_type == "header") { - boost::shared_ptr<TProtocolFactory> headerProtocolFactory(new THeaderProtocolFactory()); + stdcxx::shared_ptr<TProtocolFactory> headerProtocolFactory(new THeaderProtocolFactory()); protocolFactory = headerProtocolFactory; } else { TBinaryProtocolFactoryT<TBufferBase>* binaryProtocolFactory = new TBinaryProtocolFactoryT<TBufferBase>(); @@ -646,51 +646,51 @@ int main(int argc, char** argv) { } // Processor - boost::shared_ptr<TestHandler> testHandler(new TestHandler()); - boost::shared_ptr<ThriftTestProcessor> testProcessor(new ThriftTestProcessor(testHandler)); + stdcxx::shared_ptr<TestHandler> testHandler(new TestHandler()); + stdcxx::shared_ptr<ThriftTestProcessor> testProcessor(new ThriftTestProcessor(testHandler)); if (vm.count("processor-events")) { testProcessor->setEventHandler( - boost::shared_ptr<TProcessorEventHandler>(new TestProcessorEventHandler())); + stdcxx::shared_ptr<TProcessorEventHandler>(new TestProcessorEventHandler())); } // Transport - boost::shared_ptr<TSSLSocketFactory> sslSocketFactory; - boost::shared_ptr<TServerSocket> serverSocket; + stdcxx::shared_ptr<TSSLSocketFactory> sslSocketFactory; + stdcxx::shared_ptr<TServerSocket> serverSocket; if (ssl) { - sslSocketFactory = boost::shared_ptr<TSSLSocketFactory>(new TSSLSocketFactory()); + sslSocketFactory = stdcxx::shared_ptr<TSSLSocketFactory>(new TSSLSocketFactory()); sslSocketFactory->loadCertificate(certPath.c_str()); sslSocketFactory->loadPrivateKey(keyPath.c_str()); sslSocketFactory->ciphers("ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH"); - serverSocket = boost::shared_ptr<TServerSocket>(new TSSLServerSocket(port, sslSocketFactory)); + serverSocket = stdcxx::shared_ptr<TServerSocket>(new TSSLServerSocket(port, sslSocketFactory)); } else { if (domain_socket != "") { if (abstract_namespace) { std::string abstract_socket("\0", 1); abstract_socket += domain_socket; - serverSocket = boost::shared_ptr<TServerSocket>(new TServerSocket(abstract_socket)); + serverSocket = stdcxx::shared_ptr<TServerSocket>(new TServerSocket(abstract_socket)); } else { unlink(domain_socket.c_str()); - serverSocket = boost::shared_ptr<TServerSocket>(new TServerSocket(domain_socket)); + serverSocket = stdcxx::shared_ptr<TServerSocket>(new TServerSocket(domain_socket)); } port = 0; } else { - serverSocket = boost::shared_ptr<TServerSocket>(new TServerSocket(port)); + serverSocket = stdcxx::shared_ptr<TServerSocket>(new TServerSocket(port)); } } // Factory - boost::shared_ptr<TTransportFactory> transportFactory; + stdcxx::shared_ptr<TTransportFactory> transportFactory; if (transport_type == "http" && server_type != "nonblocking") { - boost::shared_ptr<TTransportFactory> httpTransportFactory(new THttpServerTransportFactory()); + stdcxx::shared_ptr<TTransportFactory> httpTransportFactory(new THttpServerTransportFactory()); transportFactory = httpTransportFactory; } else if (transport_type == "framed") { - boost::shared_ptr<TTransportFactory> framedTransportFactory(new TFramedTransportFactory()); + stdcxx::shared_ptr<TTransportFactory> framedTransportFactory(new TFramedTransportFactory()); transportFactory = framedTransportFactory; } else { - boost::shared_ptr<TTransportFactory> bufferedTransportFactory(new TBufferedTransportFactory()); + stdcxx::shared_ptr<TTransportFactory> bufferedTransportFactory(new TBufferedTransportFactory()); transportFactory = bufferedTransportFactory; } @@ -707,16 +707,16 @@ int main(int argc, char** argv) { cout << endl; // Server - boost::shared_ptr<apache::thrift::server::TServer> server; + stdcxx::shared_ptr<apache::thrift::server::TServer> server; if (server_type == "simple") { server.reset(new TSimpleServer(testProcessor, serverSocket, transportFactory, protocolFactory)); } else if (server_type == "thread-pool") { - boost::shared_ptr<ThreadManager> threadManager = ThreadManager::newSimpleThreadManager(workers); + stdcxx::shared_ptr<ThreadManager> threadManager = ThreadManager::newSimpleThreadManager(workers); - boost::shared_ptr<PlatformThreadFactory> threadFactory - = boost::shared_ptr<PlatformThreadFactory>(new PlatformThreadFactory()); + stdcxx::shared_ptr<PlatformThreadFactory> threadFactory + = stdcxx::shared_ptr<PlatformThreadFactory>(new PlatformThreadFactory()); threadManager->threadFactory(threadFactory); @@ -733,10 +733,10 @@ int main(int argc, char** argv) { new TThreadedServer(testProcessor, serverSocket, transportFactory, protocolFactory)); } else if (server_type == "nonblocking") { if (transport_type == "http") { - boost::shared_ptr<TestHandlerAsync> testHandlerAsync(new TestHandlerAsync(testHandler)); - boost::shared_ptr<TAsyncProcessor> testProcessorAsync( + stdcxx::shared_ptr<TestHandlerAsync> testHandlerAsync(new TestHandlerAsync(testHandler)); + stdcxx::shared_ptr<TAsyncProcessor> testProcessorAsync( new ThriftTestAsyncProcessor(testHandlerAsync)); - boost::shared_ptr<TAsyncBufferProcessor> testBufferProcessor( + stdcxx::shared_ptr<TAsyncBufferProcessor> testBufferProcessor( new TAsyncProtocolProcessor(testProcessorAsync, protocolFactory)); // not loading nonblockingServer into "server" because @@ -745,7 +745,7 @@ int main(int argc, char** argv) { TEvhttpServer nonblockingServer(testBufferProcessor, port); nonblockingServer.serve(); } else { - boost::shared_ptr<transport::TNonblockingServerSocket> nbSocket; + stdcxx::shared_ptr<transport::TNonblockingServerSocket> nbSocket; nbSocket.reset(new transport::TNonblockingServerSocket(port)); server.reset(new TNonblockingServer(testProcessor, protocolFactory, nbSocket)); } @@ -755,12 +755,12 @@ 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(boost::shared_ptr<TProtocolFactory>()); + server->setOutputProtocolFactory(stdcxx::shared_ptr<TProtocolFactory>()); } apache::thrift::concurrency::PlatformThreadFactory factory; factory.setDetached(false); - boost::shared_ptr<apache::thrift::concurrency::Runnable> serverThreadRunner(server); - boost::shared_ptr<apache::thrift::concurrency::Thread> thread + stdcxx::shared_ptr<apache::thrift::concurrency::Runnable> serverThreadRunner(server); + stdcxx::shared_ptr<apache::thrift::concurrency::Thread> thread = factory.newThread(serverThreadRunner); thread->start(); diff --git a/tutorial/cpp/CppClient.cpp b/tutorial/cpp/CppClient.cpp index 2763fee5e..f10c72557 100644 --- a/tutorial/cpp/CppClient.cpp +++ b/tutorial/cpp/CppClient.cpp @@ -22,6 +22,7 @@ #include <thrift/protocol/TBinaryProtocol.h> #include <thrift/transport/TSocket.h> #include <thrift/transport/TTransportUtils.h> +#include <thrift/stdcxx.h> #include "../gen-cpp/Calculator.h" @@ -34,9 +35,9 @@ using namespace tutorial; using namespace shared; int main() { - boost::shared_ptr<TTransport> socket(new TSocket("localhost", 9090)); - boost::shared_ptr<TTransport> transport(new TBufferedTransport(socket)); - boost::shared_ptr<TProtocol> protocol(new TBinaryProtocol(transport)); + 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)); CalculatorClient client(protocol); try { diff --git a/tutorial/cpp/CppServer.cpp b/tutorial/cpp/CppServer.cpp index eafffa973..80b100e59 100644 --- a/tutorial/cpp/CppServer.cpp +++ b/tutorial/cpp/CppServer.cpp @@ -27,8 +27,7 @@ #include <thrift/transport/TSocket.h> #include <thrift/transport/TTransportUtils.h> #include <thrift/TToString.h> - -#include <boost/make_shared.hpp> +#include <thrift/stdcxx.h> #include <iostream> #include <stdexcept> @@ -118,7 +117,7 @@ class CalculatorCloneFactory : virtual public CalculatorIfFactory { virtual ~CalculatorCloneFactory() {} virtual CalculatorIf* getHandler(const ::apache::thrift::TConnectionInfo& connInfo) { - boost::shared_ptr<TSocket> sock = boost::dynamic_pointer_cast<TSocket>(connInfo.transport); + stdcxx::shared_ptr<TSocket> sock = stdcxx::dynamic_pointer_cast<TSocket>(connInfo.transport); cout << "Incoming connection\n"; cout << "\tSocketInfo: " << sock->getSocketInfo() << "\n"; cout << "\tPeerHost: " << sock->getPeerHost() << "\n"; @@ -133,18 +132,18 @@ class CalculatorCloneFactory : virtual public CalculatorIfFactory { int main() { TThreadedServer server( - boost::make_shared<CalculatorProcessorFactory>(boost::make_shared<CalculatorCloneFactory>()), - boost::make_shared<TServerSocket>(9090), //port - boost::make_shared<TBufferedTransportFactory>(), - boost::make_shared<TBinaryProtocolFactory>()); + stdcxx::make_shared<CalculatorProcessorFactory>(stdcxx::make_shared<CalculatorCloneFactory>()), + stdcxx::make_shared<TServerSocket>(9090), //port + stdcxx::make_shared<TBufferedTransportFactory>(), + stdcxx::make_shared<TBinaryProtocolFactory>()); /* // if you don't need per-connection state, do the following instead TThreadedServer server( - boost::make_shared<CalculatorProcessor>(boost::make_shared<CalculatorHandler>()), - boost::make_shared<TServerSocket>(9090), //port - boost::make_shared<TBufferedTransportFactory>(), - boost::make_shared<TBinaryProtocolFactory>()); + stdcxx::make_shared<CalculatorProcessor>(stdcxx::make_shared<CalculatorHandler>()), + stdcxx::make_shared<TServerSocket>(9090), //port + stdcxx::make_shared<TBufferedTransportFactory>(), + stdcxx::make_shared<TBinaryProtocolFactory>()); */ /** @@ -152,25 +151,25 @@ int main() { // This server only allows one connection at a time, but spawns no threads TSimpleServer server( - boost::make_shared<CalculatorProcessor>(boost::make_shared<CalculatorHandler>()), - boost::make_shared<TServerSocket>(9090), - boost::make_shared<TBufferedTransportFactory>(), - boost::make_shared<TBinaryProtocolFactory>()); + stdcxx::make_shared<CalculatorProcessor>(stdcxx::make_shared<CalculatorHandler>()), + stdcxx::make_shared<TServerSocket>(9090), + stdcxx::make_shared<TBufferedTransportFactory>(), + stdcxx::make_shared<TBinaryProtocolFactory>()); const int workerCount = 4; - boost::shared_ptr<ThreadManager> threadManager = + stdcxx::shared_ptr<ThreadManager> threadManager = ThreadManager::newSimpleThreadManager(workerCount); threadManager->threadFactory( - boost::make_shared<PlatformThreadFactory>()); + stdcxx::make_shared<PlatformThreadFactory>()); threadManager->start(); // This server allows "workerCount" connection at a time, and reuses threads TThreadPoolServer server( - boost::make_shared<CalculatorProcessorFactory>(boost::make_shared<CalculatorCloneFactory>()), - boost::make_shared<TServerSocket>(9090), - boost::make_shared<TBufferedTransportFactory>(), - boost::make_shared<TBinaryProtocolFactory>(), + stdcxx::make_shared<CalculatorProcessorFactory>(stdcxx::make_shared<CalculatorCloneFactory>()), + stdcxx::make_shared<TServerSocket>(9090), + stdcxx::make_shared<TBufferedTransportFactory>(), + stdcxx::make_shared<TBinaryProtocolFactory>(), threadManager); */ |