diff options
author | Bernard Normier <bernard@zeroc.com> | 2016-08-04 16:52:11 -0400 |
---|---|---|
committer | Bernard Normier <bernard@zeroc.com> | 2016-08-04 16:52:11 -0400 |
commit | 124017bfb9469d9c081c92acee12b4eac9304758 (patch) | |
tree | e66cf548380f8d722cefd68fb26eae399e08b9d1 /cpp/src/Glacier2Lib/SessionHelper.cpp | |
parent | Update UWP test certificate (diff) | |
download | ice-124017bfb9469d9c081c92acee12b4eac9304758.tar.bz2 ice-124017bfb9469d9c081c92acee12b4eac9304758.tar.xz ice-124017bfb9469d9c081c92acee12b4eac9304758.zip |
Refactored shared_from_this/enable_shared_from_this
Diffstat (limited to 'cpp/src/Glacier2Lib/SessionHelper.cpp')
-rw-r--r-- | cpp/src/Glacier2Lib/SessionHelper.cpp | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/cpp/src/Glacier2Lib/SessionHelper.cpp b/cpp/src/Glacier2Lib/SessionHelper.cpp index 75f714a05cb..34565f357e4 100644 --- a/cpp/src/Glacier2Lib/SessionHelper.cpp +++ b/cpp/src/Glacier2Lib/SessionHelper.cpp @@ -20,7 +20,12 @@ using namespace std; namespace Glacier2 { -class SessionThreadCallback : public Ice::EnableSharedFromThis<SessionThreadCallback> +class SessionThreadCallback : +#ifdef ICE_CPP11_MAPPING + public std::enable_shared_from_this<SessionThreadCallback> +#else + public virtual IceUtil::Shared +#endif { public: @@ -82,7 +87,10 @@ private: const Glacier2::SessionCallbackPtr _callback; }; -class SessionHelperI : public Glacier2::SessionHelper, public Ice::EnableSharedFromThis<SessionHelperI> +class SessionHelperI : public Glacier2::SessionHelper +#ifdef ICE_CPP11_MAPPING + , public std::enable_shared_from_this<SessionHelperI> +#endif { public: @@ -224,13 +232,13 @@ SessionHelperI::destroy() // We destroy the communicator to trigger the immediate // failure of the connection establishment. // - IceUtil::ThreadPtr destroyCommunicator = new DestroyCommunicator(shared_from_this()); + IceUtil::ThreadPtr destroyCommunicator = new DestroyCommunicator(ICE_SHARED_FROM_THIS); _threadCB = ICE_NULLPTR; destroyCommunicator->start(); return; } - IceUtil::ThreadPtr destroyInternal = new DestroyInternal(shared_from_this(), _threadCB, _callback); + IceUtil::ThreadPtr destroyInternal = new DestroyInternal(ICE_SHARED_FROM_THIS, _threadCB, _callback); _session = ICE_NULLPTR; _connected = false; @@ -675,13 +683,13 @@ SessionHelperI::connectImpl(const ConnectStrategyPtr& factory) catch(const Ice::LocalException& ex) { _destroy = true; - IceUtil::ThreadPtr thread = new DispatchCallThread(shared_from_this(), new ConnectFailed(_callback, shared_from_this(), ex), 0); + IceUtil::ThreadPtr thread = new DispatchCallThread(ICE_SHARED_FROM_THIS, new ConnectFailed(_callback, ICE_SHARED_FROM_THIS, ex), 0); _threadCB->add(this, thread); thread->start(); return; } - IceUtil::ThreadPtr thread = new ConnectThread(_callback, shared_from_this(), factory, _communicator, _finder); + IceUtil::ThreadPtr thread = new ConnectThread(_callback, ICE_SHARED_FROM_THIS, factory, _communicator, _finder); _threadCB->add(this, thread); thread->start(); } @@ -808,7 +816,7 @@ SessionHelperI::connected(const Glacier2::RouterPrxPtr& router, const Glacier2:: self->destroy(); }); #else - connection->setCloseCallback(ICE_MAKE_SHARED(CloseCallbackI, shared_from_this())); + connection->setCloseCallback(ICE_MAKE_SHARED(CloseCallbackI, this)); #endif } } @@ -820,11 +828,11 @@ SessionHelperI::connected(const Glacier2::RouterPrxPtr& router, const Glacier2:: // connected() is only called from the ConnectThread so it is ok to // call destroyInternal here. // - destroyInternal(new Disconnected(shared_from_this(), _callback)); + destroyInternal(new Disconnected(ICE_SHARED_FROM_THIS, _callback)); } else { - dispatchCallback(new Connected(_callback, shared_from_this()), conn); + dispatchCallback(new Connected(_callback, ICE_SHARED_FROM_THIS), conn); } } @@ -1133,7 +1141,7 @@ Glacier2::SessionFactoryHelper::connect() { IceUtil::Mutex::Lock sync(_mutex); session = ICE_MAKE_SHARED(SessionHelperI, - ICE_MAKE_SHARED(SessionThreadCallback, shared_from_this()), + ICE_MAKE_SHARED(SessionThreadCallback, ICE_SHARED_FROM_THIS), _callback, createInitData(), getRouterFinderStr(), @@ -1152,7 +1160,7 @@ Glacier2::SessionFactoryHelper::connect(const string& user, const string& passw { IceUtil::Mutex::Lock sync(_mutex); session = ICE_MAKE_SHARED(SessionHelperI, - ICE_MAKE_SHARED(SessionThreadCallback, shared_from_this()), + ICE_MAKE_SHARED(SessionThreadCallback, ICE_SHARED_FROM_THIS), _callback, createInitData(), getRouterFinderStr(), |