diff --git a/Makefile b/Makefile index 4fbc899..4e4b846 100644 --- a/Makefile +++ b/Makefile @@ -122,11 +122,10 @@ build: $(LIB) $(BIN) install: $(LIB) $(BIN) mkdir -p $(PREFIX)/include/sofa/pbrpc cp -r $(PUB_INC) $(TARGET_DIRECTORY) $(PREFIX)/include/sofa/pbrpc/ - mkdir -p $(PREFIX)/include/sofa/pbrpc/boost/smart_ptr - cp src/sofa/pbrpc/boost/smart_ptr/*.hpp $(PREFIX)/include/sofa/pbrpc/boost/smart_ptr - mkdir -p $(PREFIX)/include/sofa/pbrpc/boost/smart_ptr/detail - cp src/sofa/pbrpc/boost/smart_ptr/detail/*.hpp $(PREFIX)/include/sofa/pbrpc/boost/smart_ptr/detail - cp src/sofa/pbrpc/boost/smart_ptr.hpp $(PREFIX)/include/sofa/pbrpc/boost + mkdir -p $(PREFIX)/include/sofa/pbrpc/smart_ptr + cp src/sofa/pbrpc/smart_ptr/*.hpp $(PREFIX)/include/sofa/pbrpc/smart_ptr + mkdir -p $(PREFIX)/include/sofa/pbrpc/smart_ptr/detail + cp src/sofa/pbrpc/smart_ptr/detail/*.hpp $(PREFIX)/include/sofa/pbrpc/smart_ptr/detail mkdir -p $(PREFIX)/lib cp $(LIB) $(PREFIX)/lib/ mkdir -p $(PREFIX)/bin diff --git a/README.md b/README.md index c249790..002ea74 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,9 @@ For more details, please refer to the wiki [Build Guide](https://github.com/baid ### Sample For sample code, please refer to ['./sample'](https://github.com/baidu/sofa-pbrpc/tree/master/sample) and the wiki [Quick Start](https://github.com/baidu/sofa-pbrpc/wiki/%E5%BF%AB%E9%80%9F%E4%BD%BF%E7%94%A8). +### Profiling +For Profiling feature, please refer to the wiki [Profiling](https://github.com/baidu/sofa-pbrpc/wiki/Profiling%E5%8A%9F%E8%83%BD). + ### Performance For performace details, please refer to the wiki [Performance](https://github.com/baidu/sofa-pbrpc/wiki/%E6%80%A7%E8%83%BD). diff --git a/src/sofa/pbrpc/binary_rpc_request.cc b/src/sofa/pbrpc/binary_rpc_request.cc index 71b51d6..1f831d0 100644 --- a/src/sofa/pbrpc/binary_rpc_request.cc +++ b/src/sofa/pbrpc/binary_rpc_request.cc @@ -85,7 +85,7 @@ void BinaryRpcRequest::ProcessRequest( } else { - sofa::pbrpc::boost::scoped_ptr is( + sofa::pbrpc::scoped_ptr is( get_compressed_input_stream(_req_body.get(), compress_type)); parse_request_return = request->ParseFromZeroCopyStream(is.get()); } @@ -157,7 +157,7 @@ ReadBufferPtr BinaryRpcRequest::AssembleSucceedResponse( } else { - sofa::pbrpc::boost::scoped_ptr os( + sofa::pbrpc::scoped_ptr os( get_compressed_output_stream(&write_buffer, meta.compress_type())); ser_ret = response->SerializeToZeroCopyStream(os.get()); os->Flush(); diff --git a/src/sofa/pbrpc/binary_rpc_request.h b/src/sofa/pbrpc/binary_rpc_request.h index 59c8572..45878db 100644 --- a/src/sofa/pbrpc/binary_rpc_request.h +++ b/src/sofa/pbrpc/binary_rpc_request.h @@ -15,7 +15,7 @@ namespace pbrpc { class BinaryRpcRequestParser; class BinaryRpcRequest; -typedef sofa::pbrpc::boost::shared_ptr BinaryRpcRequestPtr; +typedef sofa::pbrpc::shared_ptr BinaryRpcRequestPtr; class BinaryRpcRequest : public RpcRequest { diff --git a/src/sofa/pbrpc/buffer.h b/src/sofa/pbrpc/buffer.h index 1b6bb28..3804303 100644 --- a/src/sofa/pbrpc/buffer.h +++ b/src/sofa/pbrpc/buffer.h @@ -18,9 +18,9 @@ namespace pbrpc { // Defined in this file. class ReadBuffer; -typedef sofa::pbrpc::boost::shared_ptr ReadBufferPtr; +typedef sofa::pbrpc::shared_ptr ReadBufferPtr; class WriteBuffer; -typedef sofa::pbrpc::boost::shared_ptr WriteBufferPtr; +typedef sofa::pbrpc::shared_ptr WriteBufferPtr; typedef std::deque BufHandleList; typedef std::deque::iterator BufHandleListIterator; diff --git a/src/sofa/pbrpc/closure.h b/src/sofa/pbrpc/closure.h index c3328e9..cae37b0 100644 --- a/src/sofa/pbrpc/closure.h +++ b/src/sofa/pbrpc/closure.h @@ -20,7 +20,7 @@ // 3, Support pass argument by reference, though bind // always by value. // 4, When bind class method, support use -// "sofa::pbrpc::boost::shared_ptr" as this pointer of class. +// "sofa::pbrpc::shared_ptr" as this pointer of class. // 5, Support create temporary and permanent closure: // Temporary closure (self destoryed after call): // NewClosure(); @@ -47,7 +47,7 @@ // Closure* c3 = NewClosure(&obj, &ClassA::m1, 1, 2.0); // c3->Run(); // -// class ClassB : public sofa::pbrpc::boost::enable_shared_from_this +// class ClassB : public sofa::pbrpc::enable_shared_from_this // { // public: // int m1(int pre_arg, double post_arg); @@ -58,7 +58,7 @@ // c4->Run(2.0); // } // }; -// sofa::pbrpc::boost::shared_ptr ptr(new ClassB); +// sofa::pbrpc::shared_ptr ptr(new ClassB); // Closure* c5 = NewClosure(ptr, &ClassB::m1, 1, 2.0); // c5->Run(); // diff --git a/src/sofa/pbrpc/closure_gen.pl b/src/sofa/pbrpc/closure_gen.pl index 585af47..8464247 100644 --- a/src/sofa/pbrpc/closure_gen.pl +++ b/src/sofa/pbrpc/closure_gen.pl @@ -31,7 +31,7 @@ () print "// 3, Support pass argument by reference, though bind\n"; print "// always by value.\n"; print "// 4, When bind class method, support use\n"; - print "// \"sofa::pbrpc::boost::shared_ptr\" as this pointer of class.\n"; + print "// \"sofa::pbrpc::shared_ptr\" as this pointer of class.\n"; print "// 5, Support create temporary and permanent closure:\n"; print "// Temporary closure (self destoryed after call):\n"; print "// NewClosure();\n"; @@ -58,7 +58,7 @@ () print "// Closure* c3 = NewClosure(&obj, &ClassA::m1, 1, 2.0);\n"; print "// c3->Run();\n"; print "// \n"; - print "// class ClassB : public sofa::pbrpc::boost::enable_shared_from_this\n"; + print "// class ClassB : public sofa::pbrpc::enable_shared_from_this\n"; print "// {\n"; print "// public:\n"; print "// int m1(int pre_arg, double post_arg);\n"; @@ -69,7 +69,7 @@ () print "// c4->Run(2.0);\n"; print "// }\n"; print "// };\n"; - print "// sofa::pbrpc::boost::shared_ptr ptr(new ClassB);\n"; + print "// sofa::pbrpc::shared_ptr ptr(new ClassB);\n"; print "// Closure* c5 = NewClosure(ptr, &ClassB::m1, 1, 2.0);\n"; print "// c5->Run();\n"; print "// \n"; diff --git a/src/sofa/pbrpc/common.h b/src/sofa/pbrpc/common.h index e626ec0..8551e08 100644 --- a/src/sofa/pbrpc/common.h +++ b/src/sofa/pbrpc/common.h @@ -8,7 +8,7 @@ #include #include -#include +#include namespace std {} diff --git a/src/sofa/pbrpc/common_internal.h b/src/sofa/pbrpc/common_internal.h index ef04995..579048a 100644 --- a/src/sofa/pbrpc/common_internal.h +++ b/src/sofa/pbrpc/common_internal.h @@ -20,54 +20,54 @@ namespace sofa { namespace pbrpc { class RpcControllerImpl; -typedef sofa::pbrpc::boost::shared_ptr RpcControllerImplPtr; -typedef sofa::pbrpc::boost::weak_ptr RpcControllerImplWPtr; +typedef sofa::pbrpc::shared_ptr RpcControllerImplPtr; +typedef sofa::pbrpc::weak_ptr RpcControllerImplWPtr; class RpcChannelImpl; -typedef sofa::pbrpc::boost::shared_ptr RpcChannelImplPtr; +typedef sofa::pbrpc::shared_ptr RpcChannelImplPtr; class RpcClientImpl; -typedef sofa::pbrpc::boost::shared_ptr RpcClientImplPtr; +typedef sofa::pbrpc::shared_ptr RpcClientImplPtr; class RpcServerImpl; -typedef sofa::pbrpc::boost::shared_ptr RpcServerImplPtr; -typedef sofa::pbrpc::boost::weak_ptr RpcServerImplWPtr; +typedef sofa::pbrpc::shared_ptr RpcServerImplPtr; +typedef sofa::pbrpc::weak_ptr RpcServerImplWPtr; class RpcClientStream; -typedef sofa::pbrpc::boost::shared_ptr RpcClientStreamPtr; -typedef sofa::pbrpc::boost::weak_ptr RpcClientStreamWPtr; +typedef sofa::pbrpc::shared_ptr RpcClientStreamPtr; +typedef sofa::pbrpc::weak_ptr RpcClientStreamWPtr; class RpcServerStream; -typedef sofa::pbrpc::boost::shared_ptr RpcServerStreamPtr; -typedef sofa::pbrpc::boost::weak_ptr RpcServerStreamWPtr; +typedef sofa::pbrpc::shared_ptr RpcServerStreamPtr; +typedef sofa::pbrpc::weak_ptr RpcServerStreamWPtr; class RpcListener; -typedef sofa::pbrpc::boost::shared_ptr RpcListenerPtr; +typedef sofa::pbrpc::shared_ptr RpcListenerPtr; class TimerWorker; -typedef sofa::pbrpc::boost::shared_ptr TimerWorkerPtr; +typedef sofa::pbrpc::shared_ptr TimerWorkerPtr; class RpcTimeoutManager; -typedef sofa::pbrpc::boost::shared_ptr RpcTimeoutManagerPtr; +typedef sofa::pbrpc::shared_ptr RpcTimeoutManagerPtr; class ThreadGroup; -typedef sofa::pbrpc::boost::shared_ptr ThreadGroupPtr; +typedef sofa::pbrpc::shared_ptr ThreadGroupPtr; class ServicePool; -typedef sofa::pbrpc::boost::shared_ptr ServicePoolPtr; -typedef sofa::pbrpc::boost::weak_ptr ServicePoolWPtr; +typedef sofa::pbrpc::shared_ptr ServicePoolPtr; +typedef sofa::pbrpc::weak_ptr ServicePoolWPtr; class FlowController; -typedef sofa::pbrpc::boost::shared_ptr FlowControllerPtr; +typedef sofa::pbrpc::shared_ptr FlowControllerPtr; class WaitEvent; -typedef sofa::pbrpc::boost::shared_ptr WaitEventPtr; +typedef sofa::pbrpc::shared_ptr WaitEventPtr; class IOServicePool; -typedef sofa::pbrpc::boost::shared_ptr IOServicePoolPtr; +typedef sofa::pbrpc::shared_ptr IOServicePoolPtr; class WebService; -typedef sofa::pbrpc::boost::shared_ptr WebServicePtr; +typedef sofa::pbrpc::shared_ptr WebServicePtr; #define SOFA_PBRPC_DECLARE_RESOURCE_COUNTER(name_) \ extern sofa::pbrpc::AtomicCounter g_sofa_counter_##name_ diff --git a/src/sofa/pbrpc/dynamic_rpc_channel_impl.cc b/src/sofa/pbrpc/dynamic_rpc_channel_impl.cc index 4b5afd5..4478c6a 100644 --- a/src/sofa/pbrpc/dynamic_rpc_channel_impl.cc +++ b/src/sofa/pbrpc/dynamic_rpc_channel_impl.cc @@ -11,24 +11,24 @@ namespace pbrpc { class EventHandlerImp : public RpcChannel::EventHandler { public: - EventHandlerImp(::sofa::pbrpc::boost::weak_ptr channel) : _channel(channel) {} + EventHandlerImp(::sofa::pbrpc::weak_ptr channel) : _channel(channel) {} virtual ~EventHandlerImp() {} virtual void OnAddressAdded(const std::vector& address_list) { - ::sofa::pbrpc::boost::shared_ptr channel = _channel.lock(); + ::sofa::pbrpc::shared_ptr channel = _channel.lock(); if (channel) { channel->OnAddressAdded(address_list); } } virtual void OnAddressRemoved(const std::vector& address_list) { - ::sofa::pbrpc::boost::shared_ptr channel = _channel.lock(); + ::sofa::pbrpc::shared_ptr channel = _channel.lock(); if (channel) { channel->OnAddressRemoved(address_list); } } private: - ::sofa::pbrpc::boost::weak_ptr _channel; + ::sofa::pbrpc::weak_ptr _channel; }; DynamicRpcChannelImpl::DynamicRpcChannelImpl( diff --git a/src/sofa/pbrpc/dynamic_rpc_channel_impl.h b/src/sofa/pbrpc/dynamic_rpc_channel_impl.h index 86b7c24..616ce87 100644 --- a/src/sofa/pbrpc/dynamic_rpc_channel_impl.h +++ b/src/sofa/pbrpc/dynamic_rpc_channel_impl.h @@ -16,13 +16,13 @@ #include #include #include -#include +#include namespace sofa { namespace pbrpc { class DynamicRpcChannelImpl : public RpcChannelImpl, - public ::sofa::pbrpc::boost::enable_shared_from_this + public ::sofa::pbrpc::enable_shared_from_this { public: // Detect timeout, 3 second. @@ -46,10 +46,10 @@ class DynamicRpcChannelImpl : public RpcChannelImpl, volatile bool is_removed; // if this address is already removed. volatile bool is_channel_inited; // if the channel is already inited. LockType channel_init_lock; - ::sofa::pbrpc::boost::shared_ptr channel; + ::sofa::pbrpc::shared_ptr channel; volatile bool is_builtin_service_inited; // if the builtin service is already inited. LockType builtin_service_init_lock; - ::sofa::pbrpc::boost::scoped_ptr builtin_service; + ::sofa::pbrpc::scoped_ptr builtin_service; uint64 last_request_seq; // the last request sequence number sent by this channel. ServerContext(const std::string& server_address_); @@ -57,7 +57,7 @@ class DynamicRpcChannelImpl : public RpcChannelImpl, bool InitChannel(const RpcClientImplPtr& client_impl, const RpcChannelOptions& options); bool InitBuiltinService(const RpcChannelOptions& options); }; - typedef ::sofa::pbrpc::boost::shared_ptr ServerContextPtr; + typedef ::sofa::pbrpc::shared_ptr ServerContextPtr; typedef std::map ServerContextMap; struct AddResult { diff --git a/src/sofa/pbrpc/ext_closure.h b/src/sofa/pbrpc/ext_closure.h index c3434ba..fb5a85a 100644 --- a/src/sofa/pbrpc/ext_closure.h +++ b/src/sofa/pbrpc/ext_closure.h @@ -14,7 +14,7 @@ // 2, Support pass argument by reference, though bind // always by value. // 3, When bind class method, support use -// "sofa::pbrpc::boost::shared_ptr" as this pointer of class. +// "sofa::pbrpc::shared_ptr" as this pointer of class. // 4, Support create temporary and permanent closure: // Temporary closure (self destoryed after call): // NewExtClosure(); @@ -50,7 +50,7 @@ // ExtClosure* c4 = NewPermanentExtClosure(&obj, &C1::m1, 1); // c4->Run(2.0); // -// class C2 : public sofa::pbrpc::boost::enable_shared_from_this +// class C2 : public sofa::pbrpc::enable_shared_from_this // { // public: // int m1(int pre_arg, double post_arg); diff --git a/src/sofa/pbrpc/ext_closure_gen.pl b/src/sofa/pbrpc/ext_closure_gen.pl index f297c65..907d046 100644 --- a/src/sofa/pbrpc/ext_closure_gen.pl +++ b/src/sofa/pbrpc/ext_closure_gen.pl @@ -26,7 +26,7 @@ () print "// 2, Support pass argument by reference, though bind\n"; print "// always by value.\n"; print "// 3, When bind class method, support use\n"; - print "// \"sofa::pbrpc::boost::shared_ptr\" as this pointer of class.\n"; + print "// \"sofa::pbrpc::shared_ptr\" as this pointer of class.\n"; print "// 4, Support create temporary and permanent closure:\n"; print "// Temporary closure (self destoryed after call):\n"; print "// NewExtClosure();\n"; @@ -62,7 +62,7 @@ () print "// ExtClosure* c4 = NewPermanentExtClosure(&obj, &C1::m1, 1);\n"; print "// c4->Run(2.0);\n"; print "// \n"; - print "// class C2 : public sofa::pbrpc::boost::enable_shared_from_this\n"; + print "// class C2 : public sofa::pbrpc::enable_shared_from_this\n"; print "// {\n"; print "// public:\n"; print "// int m1(int pre_arg, double post_arg);\n"; diff --git a/src/sofa/pbrpc/http-agent/http_agent.h b/src/sofa/pbrpc/http-agent/http_agent.h index d8d99ae..8c46c3a 100644 --- a/src/sofa/pbrpc/http-agent/http_agent.h +++ b/src/sofa/pbrpc/http-agent/http_agent.h @@ -54,7 +54,7 @@ class HttpAgent ::google::protobuf::Closure* done); private: - static void CallMethodDone(const sofa::pbrpc::boost::shared_ptr& cntl, + static void CallMethodDone(const sofa::pbrpc::shared_ptr& cntl, std::string* response, ::google::protobuf::Message* request_message, ::google::protobuf::Message* response_message, diff --git a/src/sofa/pbrpc/http_rpc_request.h b/src/sofa/pbrpc/http_rpc_request.h index 25fe1c8..9fe1937 100644 --- a/src/sofa/pbrpc/http_rpc_request.h +++ b/src/sofa/pbrpc/http_rpc_request.h @@ -17,7 +17,7 @@ namespace pbrpc { class HTTPRpcRequestParser; class HTTPRpcRequest; -typedef sofa::pbrpc::boost::shared_ptr HTTPRpcRequestPtr; +typedef sofa::pbrpc::shared_ptr HTTPRpcRequestPtr; struct HTTPResponse; diff --git a/src/sofa/pbrpc/io_service.h b/src/sofa/pbrpc/io_service.h index 340980f..378045f 100644 --- a/src/sofa/pbrpc/io_service.h +++ b/src/sofa/pbrpc/io_service.h @@ -46,16 +46,16 @@ namespace sofa { namespace pbrpc { typedef sofa::pbrpc::boost::asio::io_service IOService; -typedef sofa::pbrpc::boost::shared_ptr IOServicePtr; +typedef sofa::pbrpc::shared_ptr IOServicePtr; typedef sofa::pbrpc::boost::asio::io_service::work IOServiceWork; -typedef sofa::pbrpc::boost::shared_ptr IOServiceWorkPtr; +typedef sofa::pbrpc::shared_ptr IOServiceWorkPtr; typedef sofa::pbrpc::boost::asio::io_service::strand IOServiceStrand; -typedef sofa::pbrpc::boost::shared_ptr IOServiceStrandPtr; +typedef sofa::pbrpc::shared_ptr IOServiceStrandPtr; typedef sofa::pbrpc::boost::asio::deadline_timer IOServiceTimer; -typedef sofa::pbrpc::boost::shared_ptr IOServiceTimerPtr; +typedef sofa::pbrpc::shared_ptr IOServiceTimerPtr; } // namespace pbrpc } // namespace sofa diff --git a/src/sofa/pbrpc/rpc_byte_stream.h b/src/sofa/pbrpc/rpc_byte_stream.h index 3d76c53..f93122c 100644 --- a/src/sofa/pbrpc/rpc_byte_stream.h +++ b/src/sofa/pbrpc/rpc_byte_stream.h @@ -35,7 +35,7 @@ namespace pbrpc { using sofa::pbrpc::boost::asio::ip::tcp; using namespace sofa::pbrpc::boost::asio; -class RpcByteStream : public sofa::pbrpc::boost::enable_shared_from_this +class RpcByteStream : public sofa::pbrpc::enable_shared_from_this { public: RpcByteStream(IOService& io_service, const RpcEndpoint& endpoint) diff --git a/src/sofa/pbrpc/rpc_channel.h b/src/sofa/pbrpc/rpc_channel.h index cfd2b5b..b5efa34 100644 --- a/src/sofa/pbrpc/rpc_channel.h +++ b/src/sofa/pbrpc/rpc_channel.h @@ -106,13 +106,13 @@ class RpcChannel : public google::protobuf::RpcChannel ::google::protobuf::Closure* done); public: - const sofa::pbrpc::boost::shared_ptr& impl() const + const sofa::pbrpc::shared_ptr& impl() const { return _impl; } private: - sofa::pbrpc::boost::shared_ptr _impl; + sofa::pbrpc::shared_ptr _impl; SOFA_PBRPC_DISALLOW_EVIL_CONSTRUCTORS(RpcChannel); }; // class RpcChannel diff --git a/src/sofa/pbrpc/rpc_client.h b/src/sofa/pbrpc/rpc_client.h index 1be5d7c..33f661a 100644 --- a/src/sofa/pbrpc/rpc_client.h +++ b/src/sofa/pbrpc/rpc_client.h @@ -84,13 +84,13 @@ class RpcClient void Shutdown(); public: - const sofa::pbrpc::boost::shared_ptr& impl() const + const sofa::pbrpc::shared_ptr& impl() const { return _impl; } private: - sofa::pbrpc::boost::shared_ptr _impl; + sofa::pbrpc::shared_ptr _impl; SOFA_PBRPC_DISALLOW_EVIL_CONSTRUCTORS(RpcClient); }; // class RpcClient diff --git a/src/sofa/pbrpc/rpc_client_impl.cc b/src/sofa/pbrpc/rpc_client_impl.cc index 075215a..a66a2bc 100644 --- a/src/sofa/pbrpc/rpc_client_impl.cc +++ b/src/sofa/pbrpc/rpc_client_impl.cc @@ -302,7 +302,7 @@ void RpcClientImpl::CallMethod(const google::protobuf::Message* request, } else { - ::sofa::pbrpc::boost::scoped_ptr os( + ::sofa::pbrpc::scoped_ptr os( get_compressed_output_stream(&write_buffer, meta.compress_type())); serialize_request_return = request->SerializeToZeroCopyStream(os.get()); os->Flush(); @@ -445,7 +445,7 @@ void RpcClientImpl::DoneCallback(google::protobuf::Message* response, } else { - ::sofa::pbrpc::boost::scoped_ptr is( + ::sofa::pbrpc::scoped_ptr is( get_compressed_input_stream(buffer.get(), compress_type)); parse_response_return = response->ParseFromZeroCopyStream(is.get()); } diff --git a/src/sofa/pbrpc/rpc_client_impl.h b/src/sofa/pbrpc/rpc_client_impl.h index 65fcdd9..858945c 100644 --- a/src/sofa/pbrpc/rpc_client_impl.h +++ b/src/sofa/pbrpc/rpc_client_impl.h @@ -19,7 +19,7 @@ namespace sofa { namespace pbrpc { -class RpcClientImpl: public sofa::pbrpc::boost::enable_shared_from_this +class RpcClientImpl: public sofa::pbrpc::enable_shared_from_this { public: static const int MAINTAIN_INTERVAL_IN_MS = 100; diff --git a/src/sofa/pbrpc/rpc_client_stream.h b/src/sofa/pbrpc/rpc_client_stream.h index 90a4f86..37b2c7c 100644 --- a/src/sofa/pbrpc/rpc_client_stream.h +++ b/src/sofa/pbrpc/rpc_client_stream.h @@ -108,7 +108,7 @@ class RpcClientStream : public RpcMessageStream if (_closed_stream_callback) { _closed_stream_callback( - sofa::pbrpc::boost::dynamic_pointer_cast(shared_from_this())); + sofa::pbrpc::dynamic_pointer_cast(shared_from_this())); } } diff --git a/src/sofa/pbrpc/rpc_controller.h b/src/sofa/pbrpc/rpc_controller.h index 7f3e62d..f8db4d1 100644 --- a/src/sofa/pbrpc/rpc_controller.h +++ b/src/sofa/pbrpc/rpc_controller.h @@ -163,13 +163,13 @@ class RpcController : public google::protobuf::RpcController virtual void NotifyOnCancel(google::protobuf::Closure* callback); public: - const sofa::pbrpc::boost::shared_ptr& impl() const + const sofa::pbrpc::shared_ptr& impl() const { return _impl; } private: - sofa::pbrpc::boost::shared_ptr _impl; + sofa::pbrpc::shared_ptr _impl; SOFA_PBRPC_DISALLOW_EVIL_CONSTRUCTORS(RpcController); }; // class RpcController diff --git a/src/sofa/pbrpc/rpc_controller_impl.h b/src/sofa/pbrpc/rpc_controller_impl.h index 021a57c..7483051 100644 --- a/src/sofa/pbrpc/rpc_controller_impl.h +++ b/src/sofa/pbrpc/rpc_controller_impl.h @@ -23,7 +23,7 @@ namespace pbrpc { #define CompressTypeAuto ((CompressType)-1) -class RpcControllerImpl : public sofa::pbrpc::boost::enable_shared_from_this +class RpcControllerImpl : public sofa::pbrpc::enable_shared_from_this { public: typedef sofa::pbrpc::boost::function InternalDoneCallback; diff --git a/src/sofa/pbrpc/rpc_listener.h b/src/sofa/pbrpc/rpc_listener.h index 5e6f651..7d35ec2 100644 --- a/src/sofa/pbrpc/rpc_listener.h +++ b/src/sofa/pbrpc/rpc_listener.h @@ -16,7 +16,7 @@ namespace pbrpc { using sofa::pbrpc::boost::asio::ip::tcp; -class RpcListener : public sofa::pbrpc::boost::enable_shared_from_this +class RpcListener : public sofa::pbrpc::enable_shared_from_this { // Callback function when created or accepted a new connection. typedef sofa::pbrpc::boost::function Callback; diff --git a/src/sofa/pbrpc/rpc_request.h b/src/sofa/pbrpc/rpc_request.h index f0b8f93..06dd90e 100644 --- a/src/sofa/pbrpc/rpc_request.h +++ b/src/sofa/pbrpc/rpc_request.h @@ -11,17 +11,17 @@ #include #include #include -#include -#include +#include +#include namespace sofa { namespace pbrpc { class RpcRequest; -typedef sofa::pbrpc::boost::shared_ptr RpcRequestPtr; +typedef sofa::pbrpc::shared_ptr RpcRequestPtr; -class RpcRequest : public sofa::pbrpc::boost::enable_shared_from_this +class RpcRequest : public sofa::pbrpc::enable_shared_from_this { public: enum RpcRequestType diff --git a/src/sofa/pbrpc/rpc_request_parser.h b/src/sofa/pbrpc/rpc_request_parser.h index 62cc882..8e7fc75 100644 --- a/src/sofa/pbrpc/rpc_request_parser.h +++ b/src/sofa/pbrpc/rpc_request_parser.h @@ -13,7 +13,7 @@ namespace sofa { namespace pbrpc { class RpcRequestParser; -typedef sofa::pbrpc::boost::shared_ptr RpcRequestParserPtr; +typedef sofa::pbrpc::shared_ptr RpcRequestParserPtr; class RpcRequestParser { diff --git a/src/sofa/pbrpc/rpc_server.h b/src/sofa/pbrpc/rpc_server.h index b4d366b..69f5f5d 100644 --- a/src/sofa/pbrpc/rpc_server.h +++ b/src/sofa/pbrpc/rpc_server.h @@ -186,13 +186,13 @@ class RpcServer Servlet UnregisterWebServlet(const std::string& path); public: - const sofa::pbrpc::boost::shared_ptr& impl() const + const sofa::pbrpc::shared_ptr& impl() const { return _impl; } private: - sofa::pbrpc::boost::shared_ptr _impl; + sofa::pbrpc::shared_ptr _impl; SOFA_PBRPC_DISALLOW_EVIL_CONSTRUCTORS(RpcServer); }; // class RpcServer diff --git a/src/sofa/pbrpc/rpc_server_impl.h b/src/sofa/pbrpc/rpc_server_impl.h index 19e7114..006d76b 100644 --- a/src/sofa/pbrpc/rpc_server_impl.h +++ b/src/sofa/pbrpc/rpc_server_impl.h @@ -20,7 +20,7 @@ namespace sofa { namespace pbrpc { -class RpcServerImpl : public sofa::pbrpc::boost::enable_shared_from_this +class RpcServerImpl : public sofa::pbrpc::enable_shared_from_this { public: static const int MAINTAIN_INTERVAL_IN_MS = 100; diff --git a/src/sofa/pbrpc/rpc_server_stream.h b/src/sofa/pbrpc/rpc_server_stream.h index 7db196e..23f9b9d 100644 --- a/src/sofa/pbrpc/rpc_server_stream.h +++ b/src/sofa/pbrpc/rpc_server_stream.h @@ -105,7 +105,7 @@ class RpcServerStream : public RpcServerMessageStream if (_closed_stream_callback) { _closed_stream_callback( - sofa::pbrpc::boost::dynamic_pointer_cast(shared_from_this())); + sofa::pbrpc::dynamic_pointer_cast(shared_from_this())); } } @@ -145,7 +145,7 @@ class RpcServerStream : public RpcServerMessageStream if (_received_request_callback) { _received_request_callback( - sofa::pbrpc::boost::dynamic_pointer_cast(shared_from_this()), + sofa::pbrpc::dynamic_pointer_cast(shared_from_this()), request); } } diff --git a/src/sofa/pbrpc/rpc_timeout_manager.h b/src/sofa/pbrpc/rpc_timeout_manager.h index 5464292..cfe19f8 100644 --- a/src/sofa/pbrpc/rpc_timeout_manager.h +++ b/src/sofa/pbrpc/rpc_timeout_manager.h @@ -21,7 +21,7 @@ namespace sofa { namespace pbrpc { -class RpcTimeoutManager : public sofa::pbrpc::boost::enable_shared_from_this +class RpcTimeoutManager : public sofa::pbrpc::enable_shared_from_this { public: RpcTimeoutManager(IOService& io_service) diff --git a/src/sofa/pbrpc/simple_rpc_channel_impl.h b/src/sofa/pbrpc/simple_rpc_channel_impl.h index 1fa92f7..220ac1a 100644 --- a/src/sofa/pbrpc/simple_rpc_channel_impl.h +++ b/src/sofa/pbrpc/simple_rpc_channel_impl.h @@ -11,13 +11,13 @@ #include #include #include -#include +#include namespace sofa { namespace pbrpc { class SimpleRpcChannelImpl : public RpcChannelImpl, - public ::sofa::pbrpc::boost::enable_shared_from_this + public ::sofa::pbrpc::enable_shared_from_this { public: SimpleRpcChannelImpl(const RpcClientImplPtr& rpc_client_impl, diff --git a/src/sofa/pbrpc/string_utils.cc b/src/sofa/pbrpc/string_utils.cc index f9fa594..6fd569f 100644 --- a/src/sofa/pbrpc/string_utils.cc +++ b/src/sofa/pbrpc/string_utils.cc @@ -9,7 +9,7 @@ #include #include -#include +#include namespace sofa { namespace pbrpc { @@ -201,7 +201,7 @@ static int c_escape_string_internal(const char* src, int src_len, char* dest, in std::string StringUtils::c_escape_string(const char* src, int src_len) { int dest_length = src_len * 4 + 1; // Maximum space needed - sofa::pbrpc::boost::scoped_array dest(new char[dest_length]); + sofa::pbrpc::scoped_array dest(new char[dest_length]); int len = c_escape_string_internal(src, src_len, dest.get(), dest_length); assert(len >= 0); return std::string(dest.get(), len); @@ -297,7 +297,7 @@ static int unescape_c_escape_sequences(const char* source, char* dest) std::string StringUtils::unescape_c_escape_string(const std::string& src) { - sofa::pbrpc::boost::scoped_array unescaped(new char[src.size() + 1]); + sofa::pbrpc::scoped_array unescaped(new char[src.size() + 1]); int len = unescape_c_escape_sequences(src.c_str(), unescaped.get()); return std::string(unescaped.get(), len); } diff --git a/src/sofa/pbrpc/thread_group.h b/src/sofa/pbrpc/thread_group.h index 31cb1d7..97c0832 100644 --- a/src/sofa/pbrpc/thread_group.h +++ b/src/sofa/pbrpc/thread_group.h @@ -13,7 +13,7 @@ namespace pbrpc { // Defined in this file. class ThreadGroup; -typedef sofa::pbrpc::boost::shared_ptr ThreadGroupPtr; +typedef sofa::pbrpc::shared_ptr ThreadGroupPtr; // Defined in other files. class ThreadGroupImpl; @@ -57,7 +57,7 @@ class ThreadGroup void post(ExtClosure* handler); private: - sofa::pbrpc::boost::shared_ptr _imp; + sofa::pbrpc::shared_ptr _imp; SOFA_PBRPC_DISALLOW_EVIL_CONSTRUCTORS(ThreadGroup); }; diff --git a/src/sofa/pbrpc/thread_group_impl.h b/src/sofa/pbrpc/thread_group_impl.h index 51fb805..96874f0 100644 --- a/src/sofa/pbrpc/thread_group_impl.h +++ b/src/sofa/pbrpc/thread_group_impl.h @@ -19,7 +19,7 @@ namespace pbrpc { // Defined in this file. class ThreadGroupImpl; -typedef sofa::pbrpc::boost::shared_ptr ThreadGroupImplPtr; +typedef sofa::pbrpc::shared_ptr ThreadGroupImplPtr; // Thread init and destroy function. Should be permanent closure. typedef ExtClosure* ThreadInitFunc; diff --git a/src/sofa/pbrpc/timeout_manager.h b/src/sofa/pbrpc/timeout_manager.h index 0a04320..7e23743 100644 --- a/src/sofa/pbrpc/timeout_manager.h +++ b/src/sofa/pbrpc/timeout_manager.h @@ -13,7 +13,7 @@ namespace pbrpc { // Defined in this file. class TimeoutManager; -typedef sofa::pbrpc::boost::shared_ptr TimeoutManagerPtr; +typedef sofa::pbrpc::shared_ptr TimeoutManagerPtr; // Defined in other files. class TimeoutManagerImpl; @@ -88,7 +88,7 @@ class TimeoutManager bool erase(Id id); private: - sofa::pbrpc::boost::shared_ptr _imp; + sofa::pbrpc::shared_ptr _imp; SOFA_PBRPC_DISALLOW_EVIL_CONSTRUCTORS(TimeoutManager); }; diff --git a/src/sofa/pbrpc/timeout_manager_impl.h b/src/sofa/pbrpc/timeout_manager_impl.h index d79246c..a713a09 100644 --- a/src/sofa/pbrpc/timeout_manager_impl.h +++ b/src/sofa/pbrpc/timeout_manager_impl.h @@ -22,9 +22,9 @@ namespace pbrpc { // Defined in this file. class TimeoutManagerImpl; -typedef sofa::pbrpc::boost::shared_ptr TimeoutManagerImplPtr; +typedef sofa::pbrpc::shared_ptr TimeoutManagerImplPtr; -class TimeoutManagerImpl : public sofa::pbrpc::boost::enable_shared_from_this +class TimeoutManagerImpl : public sofa::pbrpc::enable_shared_from_this { public: // Thread number for timer and callbacks. diff --git a/src/sofa/pbrpc/timer_worker.h b/src/sofa/pbrpc/timer_worker.h index 6de6d9f..d9cfbe6 100644 --- a/src/sofa/pbrpc/timer_worker.h +++ b/src/sofa/pbrpc/timer_worker.h @@ -10,7 +10,7 @@ namespace sofa { namespace pbrpc { -class TimerWorker : public sofa::pbrpc::boost::enable_shared_from_this +class TimerWorker : public sofa::pbrpc::enable_shared_from_this { public: typedef sofa::pbrpc::boost::function WorkRoutine; diff --git a/src/sofa/pbrpc/web_service.h b/src/sofa/pbrpc/web_service.h index 69b8b40..d6c12d9 100644 --- a/src/sofa/pbrpc/web_service.h +++ b/src/sofa/pbrpc/web_service.h @@ -17,7 +17,7 @@ struct HTTPResponse; typedef ExtClosure* Servlet; typedef std::map > ServletMap; -typedef sofa::pbrpc::boost::shared_ptr ServletMapPtr; +typedef sofa::pbrpc::shared_ptr ServletMapPtr; class WebService { diff --git a/unit-test/test_ext_closure.cc b/unit-test/test_ext_closure.cc index d51cfe6..571df2f 100644 --- a/unit-test/test_ext_closure.cc +++ b/unit-test/test_ext_closure.cc @@ -3,7 +3,7 @@ // found in the LICENSE file. #include -#include +#include #include using namespace ::sofa::pbrpc; @@ -573,7 +573,7 @@ TEST(ExtClosure, ClassSharedPtrClosure) { printf("\r\n==============test NewExtClosure(ClassPtr)===============\r\n"); - ::sofa::pbrpc::boost::shared_ptr obj(new CTest()); + ::sofa::pbrpc::shared_ptr obj(new CTest()); // Closure0 ExtClosure* pcb = NewExtClosure(obj, &CTest::test0); @@ -582,7 +582,7 @@ TEST(ExtClosure, ClassSharedPtrClosure) pcb = NewExtClosure(obj, &CTest::test1, 'a'); pcb->Run(); - const ::sofa::pbrpc::boost::shared_ptr& obj_const_ref = obj; + const ::sofa::pbrpc::shared_ptr& obj_const_ref = obj; pcb = NewExtClosure(obj_const_ref, &CTest::test1, 'a'); pcb->Run(); @@ -691,7 +691,7 @@ class PTest2 return i - 1; } }; -int PtrFunction(const ::sofa::pbrpc::boost::shared_ptr& p1, const ::sofa::pbrpc::boost::shared_ptr& p2, int i) +int PtrFunction(const ::sofa::pbrpc::shared_ptr& p1, const ::sofa::pbrpc::shared_ptr& p2, int i) { i = p1->Add(i); i = p2->Sub(i); @@ -744,8 +744,8 @@ TEST_F(Performance, Bind_add) TEST_F(Performance, Closure_add_with_pointer) { - ::sofa::pbrpc::boost::shared_ptr p1(new PTest1()); - ::sofa::pbrpc::boost::shared_ptr p2(new PTest2()); + ::sofa::pbrpc::shared_ptr p1(new PTest1()); + ::sofa::pbrpc::shared_ptr p2(new PTest2()); for (int i = 0; i < kLoopCount;) { ExtClosure* closure = NewExtClosure(PtrFunction, p1, p2); @@ -755,8 +755,8 @@ TEST_F(Performance, Closure_add_with_pointer) TEST_F(Performance, Bind_add_with_pointer) { - ::sofa::pbrpc::boost::shared_ptr p1(new PTest1()); - ::sofa::pbrpc::boost::shared_ptr p2(new PTest2()); + ::sofa::pbrpc::shared_ptr p1(new PTest1()); + ::sofa::pbrpc::shared_ptr p2(new PTest2()); for (int i = 0; i < kLoopCount;) { boost::function func = boost::bind(PtrFunction, p1, p2, _1);