summaryrefslogtreecommitdiff
path: root/cpp
diff options
context:
space:
mode:
authorBernard Normier <bernard@zeroc.com>2016-08-04 16:52:11 -0400
committerBernard Normier <bernard@zeroc.com>2016-08-04 16:52:11 -0400
commit124017bfb9469d9c081c92acee12b4eac9304758 (patch)
treee66cf548380f8d722cefd68fb26eae399e08b9d1 /cpp
parentUpdate UWP test certificate (diff)
downloadice-124017bfb9469d9c081c92acee12b4eac9304758.tar.bz2
ice-124017bfb9469d9c081c92acee12b4eac9304758.tar.xz
ice-124017bfb9469d9c081c92acee12b4eac9304758.zip
Refactored shared_from_this/enable_shared_from_this
Diffstat (limited to 'cpp')
-rw-r--r--cpp/include/Glacier2/Application.h2
-rw-r--r--cpp/include/Glacier2/SessionHelper.h17
-rw-r--r--cpp/include/Ice/MetricsAdminI.h39
-rw-r--r--cpp/include/Ice/MetricsObserverI.h5
-rw-r--r--cpp/include/Ice/OutgoingAsync.h30
-rw-r--r--cpp/include/Ice/VirtualShared.h65
-rw-r--r--cpp/include/IceSSL/Plugin.h13
-rw-r--r--cpp/include/IceUtil/Config.h4
-rw-r--r--cpp/src/Glacier2Lib/Application.cpp10
-rw-r--r--cpp/src/Glacier2Lib/SessionHelper.cpp30
-rw-r--r--cpp/src/Ice/ACM.h12
-rw-r--r--cpp/src/Ice/CollocatedRequestHandler.cpp32
-rw-r--r--cpp/src/Ice/CollocatedRequestHandler.h11
-rw-r--r--cpp/src/Ice/CommunicatorI.h7
-rw-r--r--cpp/src/Ice/ConnectRequestHandler.cpp16
-rw-r--r--cpp/src/Ice/ConnectRequestHandler.h8
-rw-r--r--cpp/src/Ice/ConnectionFactory.cpp25
-rw-r--r--cpp/src/Ice/ConnectionFactory.h18
-rw-r--r--cpp/src/Ice/ConnectionI.cpp62
-rw-r--r--cpp/src/Ice/ConnectionI.h13
-rw-r--r--cpp/src/Ice/ConnectionRequestHandler.h7
-rw-r--r--cpp/src/Ice/EndpointI.h8
-rw-r--r--cpp/src/Ice/EventHandler.h4
-rw-r--r--cpp/src/Ice/IPEndpointI.cpp8
-rw-r--r--cpp/src/Ice/IPEndpointI.h5
-rw-r--r--cpp/src/Ice/Incoming.cpp2
-rw-r--r--cpp/src/Ice/IncomingAsync.cpp2
-rw-r--r--cpp/src/Ice/LoggerAdminI.cpp11
-rw-r--r--cpp/src/Ice/ObjectAdapterFactory.h8
-rw-r--r--cpp/src/Ice/ObjectAdapterI.h7
-rw-r--r--cpp/src/Ice/OpaqueEndpointI.cpp8
-rw-r--r--cpp/src/Ice/OpaqueEndpointI.h5
-rw-r--r--cpp/src/Ice/OutgoingAsync.cpp40
-rw-r--r--cpp/src/Ice/ResponseHandler.h7
-rw-r--r--cpp/src/Ice/RetryQueue.h7
-rw-r--r--cpp/src/Ice/RouterInfo.h6
-rw-r--r--cpp/src/Ice/Selector.cpp39
-rw-r--r--cpp/src/Ice/TcpEndpointI.cpp8
-rw-r--r--cpp/src/Ice/TcpEndpointI.h3
-rw-r--r--cpp/src/Ice/ThreadPool.cpp39
-rw-r--r--cpp/src/Ice/UdpEndpointI.cpp8
-rw-r--r--cpp/src/Ice/ValueFactoryManagerI.h4
-rw-r--r--cpp/src/Ice/VirtualShared.h43
-rw-r--r--cpp/src/Ice/WSEndpoint.cpp12
-rw-r--r--cpp/src/Ice/WSEndpoint.h5
-rw-r--r--cpp/src/Ice/ios/StreamEndpointI.cpp8
-rw-r--r--cpp/src/Ice/ios/StreamEndpointI.h15
-rw-r--r--cpp/src/IceBT/EndpointI.cpp14
-rw-r--r--cpp/src/IceBT/EndpointI.h5
-rw-r--r--cpp/src/IceBox/ServiceManagerI.cpp2
-rw-r--r--cpp/src/IceBox/ServiceManagerI.h6
-rw-r--r--cpp/src/IceDiscovery/LookupI.cpp4
-rw-r--r--cpp/src/IceDiscovery/LookupI.h16
-rw-r--r--cpp/src/IceIAP/EndpointI.h5
-rw-r--r--cpp/src/IceIAP/EndpointI.mm10
-rw-r--r--cpp/src/IceLocatorDiscovery/PluginI.cpp21
-rwxr-xr-xcpp/src/IceSSL/Certificate.cpp6
-rw-r--r--cpp/src/IceSSL/EndpointI.cpp12
-rw-r--r--cpp/src/IceSSL/EndpointI.h5
-rw-r--r--cpp/src/IceSSL/uwp/EndpointI.cpp14
-rw-r--r--cpp/test/Ice/acm/AllTests.cpp7
-rw-r--r--cpp/test/Ice/admin/TestI.cpp7
-rw-r--r--cpp/test/Ice/background/EndpointI.cpp10
-rw-r--r--cpp/test/Ice/background/EndpointI.h5
-rw-r--r--cpp/test/Ice/dispatcher/AllTests.cpp5
-rw-r--r--cpp/test/Ice/slicing/objects/AllTests.cpp5
66 files changed, 482 insertions, 415 deletions
diff --git a/cpp/include/Glacier2/Application.h b/cpp/include/Glacier2/Application.h
index 109a07e732e..9568ea11e7e 100644
--- a/cpp/include/Glacier2/Application.h
+++ b/cpp/include/Glacier2/Application.h
@@ -68,7 +68,7 @@ public:
* @see #runWithSession
**/
-class GLACIER2_API Application : public Ice::Application, public Ice::EnableSharedFromThis<Application>
+class GLACIER2_API Application : public Ice::Application
{
/**
* Initializes an instance that calls {@link Communicator#shutdown} if
diff --git a/cpp/include/Glacier2/SessionHelper.h b/cpp/include/Glacier2/SessionHelper.h
index 8fc1013c801..7447db77804 100644
--- a/cpp/include/Glacier2/SessionHelper.h
+++ b/cpp/include/Glacier2/SessionHelper.h
@@ -33,7 +33,10 @@ namespace Glacier2
const int GLACIER2_SSL_PORT = 4064;
const int GLACIER2_TCP_PORT = 4063;
-class GLACIER2_API SessionHelper : public virtual ICE_SHARED
+class GLACIER2_API SessionHelper
+#ifndef ICE_CPP11_MAPPING
+ : public virtual IceUtil::Shared
+#endif
{
public:
virtual ~SessionHelper();
@@ -51,7 +54,10 @@ public:
};
ICE_DEFINE_PTR(SessionHelperPtr, SessionHelper);
-class GLACIER2_API SessionCallback : public virtual ICE_SHARED
+class GLACIER2_API SessionCallback
+#ifndef ICE_CPP11_MAPPING
+ : public virtual IceUtil::Shared
+#endif
{
public:
virtual ~SessionCallback();
@@ -65,7 +71,12 @@ ICE_DEFINE_PTR(SessionCallbackPtr, SessionCallback);
class SessionThreadCallback;
-class GLACIER2_API SessionFactoryHelper : public Ice::EnableSharedFromThis<SessionFactoryHelper>
+class GLACIER2_API SessionFactoryHelper
+#ifdef ICE_CPP11_MAPPING
+ : public std::enable_shared_from_this<SessionFactoryHelper>
+#else
+ : public virtual IceUtil::Shared
+#endif
{
friend class SessionThreadCallback; // To access thread functions
diff --git a/cpp/include/Ice/MetricsAdminI.h b/cpp/include/Ice/MetricsAdminI.h
index 61a6903ab47..d7c045c123e 100644
--- a/cpp/include/Ice/MetricsAdminI.h
+++ b/cpp/include/Ice/MetricsAdminI.h
@@ -47,7 +47,12 @@ namespace IceInternal
class ICE_API MetricsMapI;
ICE_DEFINE_PTR(MetricsMapIPtr, MetricsMapI);
-class ICE_API MetricsMapI : public Ice::EnableSharedFromThis<MetricsMapI>
+class ICE_API MetricsMapI :
+#ifdef ICE_CPP11_MAPPING
+ public std::enable_shared_from_this<MetricsMapI>
+#else
+ public virtual IceUtil::Shared
+#endif
{
public:
@@ -121,11 +126,9 @@ protected:
const std::vector<RegExpPtr> _reject;
};
-class ICE_API MetricsMapFactory :
-#ifdef ICE_CPP11_MAPPING
- public virtual Ice::VirtualEnableSharedFromThisBase
-#else
- public Ice::LocalObject
+class ICE_API MetricsMapFactory
+#ifndef ICE_CPP11_MAPPING
+ : public Ice::LocalObject
#endif
{
public:
@@ -160,7 +163,7 @@ public:
class EntryT :
#ifdef ICE_CPP11_MAPPING
- public virtual Ice::VirtualEnableSharedFromThisBase
+ public std::enable_shared_from_this<EntryT>
#else
public Ice::LocalObject
#endif
@@ -226,7 +229,7 @@ public:
if(--_object->current == 0)
{
#ifdef ICE_CPP11_MAPPING
- _map->detached(std::dynamic_pointer_cast<EntryT>(shared_from_this()));
+ _map->detached(this->shared_from_this());
#else
_map->detached(this);
#endif
@@ -325,6 +328,13 @@ public:
{
}
+#ifdef ICE_CPP11_MAPPING
+ std::shared_ptr<MetricsMapT> shared_from_this()
+ {
+ return std::static_pointer_cast<MetricsMapT>(MetricsMapI::shared_from_this());
+ }
+#endif
+
virtual void
destroy()
{
@@ -384,11 +394,7 @@ public:
_subMaps.find(subMapName);
if(p != _subMaps.end())
{
-#ifdef ICE_CPP11_MAPPING
- return std::pair<MetricsMapIPtr, SubMapMember>(p->second.second->clone()->shared_from_this(), p->second.first);
-#else
- return std::pair<MetricsMapIPtr, SubMapMember>(p->second.second->clone(), p->second.first);
-#endif
+ return std::pair<MetricsMapIPtr, SubMapMember>(ICE_GET_SHARED_FROM_THIS(p->second.second->clone()), p->second.first);
}
return std::pair<MetricsMapIPtr, SubMapMember>(MetricsMapIPtr(ICE_NULLPTR), static_cast<SubMapMember>(0));
}
@@ -466,14 +472,15 @@ public:
{
TPtr t = ICE_MAKE_SHARED(T);
t->id = key;
+
#ifdef ICE_CPP11_MAPPING
p = _objects.insert(typename std::map<std::string, EntryTPtr>::value_type(
- key, std::make_shared<EntryT>(
- std::dynamic_pointer_cast<MetricsMapT<MetricsType>>(shared_from_this()), t, _detachedQueue.end()))).first;
+ key, std::make_shared<EntryT>(shared_from_this(), t, _detachedQueue.end()))).first;
#else
p = _objects.insert(typename std::map<std::string, EntryTPtr>::value_type(
- key, new EntryT(this, t, _detachedQueue.end()))).first;
+ key, new EntryT(this, t, _detachedQueue.end()))).first;
#endif
+
}
p->second->attach(helper);
return p->second;
diff --git a/cpp/include/Ice/MetricsObserverI.h b/cpp/include/Ice/MetricsObserverI.h
index 3ef9af54d84..cd0e6703e67 100644
--- a/cpp/include/Ice/MetricsObserverI.h
+++ b/cpp/include/Ice/MetricsObserverI.h
@@ -306,7 +306,10 @@ protected:
};
};
-class Updater : public ICE_SHARED
+class Updater
+#ifndef ICE_CPP11_MAPPING
+ : public virtual IceUtil::Shared
+#endif
{
public:
diff --git a/cpp/include/Ice/OutgoingAsync.h b/cpp/include/Ice/OutgoingAsync.h
index 0a2edead961..fafceba4f52 100644
--- a/cpp/include/Ice/OutgoingAsync.h
+++ b/cpp/include/Ice/OutgoingAsync.h
@@ -16,7 +16,6 @@
#include <Ice/CommunicatorF.h>
#include <Ice/ConnectionIF.h>
#include <Ice/ObjectAdapterF.h>
-#include <Ice/VirtualShared.h>
#include <Ice/RequestHandlerF.h>
#include <Ice/ConnectionF.h>
#include <Ice/OutputStream.h>
@@ -59,10 +58,11 @@ protected:
// invocation observer.
//
class ICE_API OutgoingAsyncBase : virtual public OutgoingAsyncCompletionCallback,
-#ifndef ICE_CPP11_MAPPING
- public Ice::AsyncResult,
+#ifdef ICE_CPP11_MAPPING
+ public std::enable_shared_from_this<OutgoingAsyncBase>
+#else
+ public Ice::AsyncResult
#endif
- public Ice::EnableSharedFromThis<OutgoingAsyncBase>
{
public:
@@ -195,8 +195,7 @@ protected:
// correctly canceled when the invocation completes.
//
class ICE_API ProxyOutgoingAsyncBase : public OutgoingAsyncBase,
- public IceUtil::TimerTask,
- public Ice::EnableSharedFromThis<ProxyOutgoingAsyncBase>
+ public IceUtil::TimerTask
{
public:
@@ -210,9 +209,12 @@ public:
void retry();
void abort(const Ice::Exception&);
- using Ice::EnableSharedFromThis<ProxyOutgoingAsyncBase>::shared_from_this;
-
-#ifndef ICE_CPP11_MAPPING
+#ifdef ICE_CPP11_MAPPING
+ std::shared_ptr<ProxyOutgoingAsyncBase> shared_from_this()
+ {
+ return std::static_pointer_cast<ProxyOutgoingAsyncBase>(OutgoingAsyncBase::shared_from_this());
+ }
+#else
virtual Ice::ObjectPrx getProxy() const;
virtual Ice::CommunicatorPtr getCommunicator() const;
#endif
@@ -358,8 +360,7 @@ typedef IceUtil::Handle<ConnectionFlushBatchAsync> ConnectionFlushBatchAsyncPtr;
//
// Class for handling Ice::Communicator::begin_flushBatchRequests
//
-class ICE_API CommunicatorFlushBatchAsync : public OutgoingAsyncBase,
- public Ice::EnableSharedFromThis<CommunicatorFlushBatchAsync>
+class ICE_API CommunicatorFlushBatchAsync : public OutgoingAsyncBase
{
public:
@@ -370,7 +371,12 @@ public:
void flushConnection(const Ice::ConnectionIPtr&);
void invoke(const std::string&);
- using Ice::EnableSharedFromThis<CommunicatorFlushBatchAsync>::shared_from_this;
+#ifdef ICE_CPP11_MAPPING
+ std::shared_ptr<CommunicatorFlushBatchAsync> shared_from_this()
+ {
+ return std::static_pointer_cast<CommunicatorFlushBatchAsync>(OutgoingAsyncBase::shared_from_this());
+ }
+#endif
private:
diff --git a/cpp/include/Ice/VirtualShared.h b/cpp/include/Ice/VirtualShared.h
deleted file mode 100644
index 72aff3df7f7..00000000000
--- a/cpp/include/Ice/VirtualShared.h
+++ /dev/null
@@ -1,65 +0,0 @@
-// **********************************************************************
-//
-// Copyright (c) 2003-2016 ZeroC, Inc. All rights reserved.
-//
-// This copy of Ice is licensed to you under the terms described in the
-// ICE_LICENSE file included in this distribution.
-//
-// **********************************************************************
-
-#ifndef ICE_VIRTUAL_SHARED_H
-#define ICE_VIRTUAL_SHARED_H
-
-#include <Ice/Config.h>
-
-namespace Ice
-{
-
-#ifdef ICE_CPP11_MAPPING // C++11
-
-class VirtualEnableSharedFromThisBase : public std::enable_shared_from_this<VirtualEnableSharedFromThisBase>
-{
-public:
-
- virtual ~VirtualEnableSharedFromThisBase() = default;
-};
-
-template<typename T> class EnableSharedFromThis : public virtual VirtualEnableSharedFromThisBase
-{
-public:
-
- std::shared_ptr<T> shared_from_this() const
- {
- return std::dynamic_pointer_cast<T>(
- std::const_pointer_cast<VirtualEnableSharedFromThisBase>(
- VirtualEnableSharedFromThisBase::shared_from_this()));
- }
-
- std::weak_ptr<T> weak_from_this() const
- {
- return shared_from_this();
- }
-};
-
-# define ICE_SHARED Ice::VirtualEnableSharedFromThisBase
-
-#else // C++98
-
-template<typename T> class EnableSharedFromThis : public virtual IceUtil::Shared
-{
-public:
-
- T* shared_from_this() const
- {
- return static_cast<T*>(const_cast<EnableSharedFromThis<T>*>(this));
- }
-};
-
-# define ICE_SHARED IceUtil::Shared
-
-
-#endif
-
-}
-
-#endif
diff --git a/cpp/include/IceSSL/Plugin.h b/cpp/include/IceSSL/Plugin.h
index 05cba8654c0..0fa64c4de8b 100644
--- a/cpp/include/IceSSL/Plugin.h
+++ b/cpp/include/IceSSL/Plugin.h
@@ -12,7 +12,6 @@
#include <IceUtil/Time.h>
#include <Ice/Plugin.h>
-#include <Ice/VirtualShared.h>
#include <IceSSL/Config.h>
#include <IceSSL/ConnectionInfo.h>
@@ -159,7 +158,10 @@ ICE_DEFINE_PTR(CertificatePtr, Certificate);
//
// A representation of a PublicKey.
//
-class ICE_SSL_API PublicKey : public Ice::EnableSharedFromThis<PublicKey>
+class ICE_SSL_API PublicKey
+#ifndef ICE_CPP11_MAPPING
+ : public virtual IceUtil::Shared
+#endif
{
public:
@@ -261,7 +263,12 @@ private:
// This convenience class is a wrapper around a native certificate.
// The interface is inspired by java.security.cert.X509Certificate.
//
-class ICE_SSL_API Certificate : public Ice::EnableSharedFromThis<Certificate>
+class ICE_SSL_API Certificate :
+#ifdef ICE_CPP11_MAPPING
+ public std::enable_shared_from_this<Certificate>
+#else
+ public virtual IceUtil::Shared
+#endif
{
public:
diff --git a/cpp/include/IceUtil/Config.h b/cpp/include/IceUtil/Config.h
index c3145efe7c6..ca711546141 100644
--- a/cpp/include/IceUtil/Config.h
+++ b/cpp/include/IceUtil/Config.h
@@ -367,6 +367,8 @@ typedef long long Int64;
# define ICE_NULLPTR nullptr
# define ICE_DYNAMIC_CAST(T,V) ::std::dynamic_pointer_cast<T>(V)
# define ICE_SHARED_FROM_THIS shared_from_this()
+# define ICE_SHARED_FROM_CONST_THIS(T) const_cast<T*>(this)->shared_from_this()
+# define ICE_GET_SHARED_FROM_THIS(p) p->shared_from_this()
# define ICE_CHECKED_CAST(T, ...) Ice::checkedCast<T>(__VA_ARGS__)
# define ICE_UNCHECKED_CAST(T, ...) Ice::uncheckedCast<T>(__VA_ARGS__)
# define ICE_VALUE_FACTORY ::std::function<::std::shared_ptr<::Ice::Value>(const std::string&)>
@@ -385,6 +387,8 @@ typedef long long Int64;
# define ICE_NULLPTR 0
# define ICE_DYNAMIC_CAST(T,V) T##Ptr::dynamicCast(V)
# define ICE_SHARED_FROM_THIS this
+# define ICE_SHARED_FROM_CONST_THIS(T) const_cast<T*>(this)
+# define ICE_GET_SHARED_FROM_THIS(p) p
# define ICE_CHECKED_CAST(T, ...) T::checkedCast(__VA_ARGS__)
# define ICE_UNCHECKED_CAST(T, ...) T::uncheckedCast(__VA_ARGS__)
# define ICE_VALUE_FACTORY ::Ice::ValueFactoryPtr
diff --git a/cpp/src/Glacier2Lib/Application.cpp b/cpp/src/Glacier2Lib/Application.cpp
index 359d440e3e7..998051be656 100644
--- a/cpp/src/Glacier2Lib/Application.cpp
+++ b/cpp/src/Glacier2Lib/Application.cpp
@@ -197,15 +197,11 @@ Glacier2::Application::doMain(Ice::StringSeq& args, const Ice::InitializationDat
assert(connection);
connection->setACM(acmTimeout, IceUtil::None, Ice::HeartbeatAlways);
#ifdef ICE_CPP11_MAPPING
- auto self = weak_from_this();
+ auto app = this;
connection->setCloseCallback(
- [self](Ice::ConnectionPtr)
+ [app](Ice::ConnectionPtr)
{
- auto s = self.lock();
- if(s)
- {
- s->sessionDestroyed();
- }
+ app->sessionDestroyed();
});
#else
connection->setCloseCallback(ICE_MAKE_SHARED(CloseCallbackI, this));
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(),
diff --git a/cpp/src/Ice/ACM.h b/cpp/src/Ice/ACM.h
index 6859669255c..32e89ac02fe 100644
--- a/cpp/src/Ice/ACM.h
+++ b/cpp/src/Ice/ACM.h
@@ -19,7 +19,6 @@
#include <Ice/InstanceF.h>
#include <Ice/PropertiesF.h>
#include <Ice/LoggerF.h>
-#include <Ice/VirtualShared.h>
#include <set>
namespace IceInternal
@@ -51,7 +50,10 @@ public:
virtual Ice::ACM getACM() = 0;
};
-class FactoryACMMonitor : public ACMMonitor, public IceUtil::Mutex, public Ice::EnableSharedFromThis<FactoryACMMonitor>
+class FactoryACMMonitor : public ACMMonitor, public IceUtil::Mutex
+#ifdef ICE_CPP11_MAPPING
+ , public std::enable_shared_from_this<FactoryACMMonitor>
+#endif
{
public:
@@ -87,8 +89,10 @@ private:
};
class ConnectionACMMonitor : public ACMMonitor,
- public IceUtil::Mutex,
- public Ice::EnableSharedFromThis<ConnectionACMMonitor>
+ public IceUtil::Mutex
+#ifdef ICE_CPP11_MAPPING
+ , public std::enable_shared_from_this<ConnectionACMMonitor>
+#endif
{
public:
diff --git a/cpp/src/Ice/CollocatedRequestHandler.cpp b/cpp/src/Ice/CollocatedRequestHandler.cpp
index b6b15cb83b8..1c061dc2b9c 100644
--- a/cpp/src/Ice/CollocatedRequestHandler.cpp
+++ b/cpp/src/Ice/CollocatedRequestHandler.cpp
@@ -37,7 +37,7 @@ public:
Int batchRequestNum) :
_out(out),
_os(os),
- _handler(handler->shared_from_this()),
+ _handler(ICE_GET_SHARED_FROM_THIS(handler)),
_requestId(requestId),
_batchRequestNum(batchRequestNum)
{
@@ -122,7 +122,7 @@ CollocatedRequestHandler::~CollocatedRequestHandler()
RequestHandlerPtr
CollocatedRequestHandler::update(const RequestHandlerPtr& previousHandler, const RequestHandlerPtr& newHandler)
{
- return previousHandler.get() == this ? newHandler : shared_from_this();
+ return previousHandler.get() == this ? newHandler : ICE_SHARED_FROM_THIS;
}
bool
@@ -269,20 +269,20 @@ CollocatedRequestHandler::invokeAsyncRequest(OutgoingAsyncBase* outAsync, int ba
//
// This will throw if the request is canceled
//
- outAsync->cancelable(shared_from_this());
+ outAsync->cancelable(ICE_SHARED_FROM_THIS);
if(_response)
{
requestId = ++_requestId;
- _asyncRequests.insert(make_pair(requestId, outAsync->shared_from_this()));
+ _asyncRequests.insert(make_pair(requestId, ICE_GET_SHARED_FROM_THIS(outAsync)));
}
- _sendAsyncRequests.insert(make_pair(outAsync->shared_from_this(), requestId));
+ _sendAsyncRequests.insert(make_pair(ICE_GET_SHARED_FROM_THIS(outAsync), requestId));
}
catch(...)
{
- _adapter->decDirectCount();
- throw;
+ _adapter->decDirectCount();
+ throw;
}
outAsync->attachCollocatedObserver(_adapter, requestId);
@@ -290,17 +290,17 @@ CollocatedRequestHandler::invokeAsyncRequest(OutgoingAsyncBase* outAsync, int ba
if(!synchronous || !_response || _reference->getInvocationTimeout() > 0)
{
// Don't invoke from the user thread if async or invocation timeout is set
- _adapter->getThreadPool()->dispatch(new InvokeAllAsync(outAsync->shared_from_this(),
- outAsync->getOs(),
- shared_from_this(),
- requestId,
- batchRequestNum));
+ _adapter->getThreadPool()->dispatch(new InvokeAllAsync(ICE_GET_SHARED_FROM_THIS(outAsync),
+ outAsync->getOs(),
+ ICE_SHARED_FROM_THIS,
+ requestId,
+ batchRequestNum));
}
else if(_dispatcher)
{
- _adapter->getThreadPool()->dispatchFromThisThread(new InvokeAllAsync(outAsync->shared_from_this(),
+ _adapter->getThreadPool()->dispatchFromThisThread(new InvokeAllAsync(ICE_GET_SHARED_FROM_THIS(outAsync),
outAsync->getOs(),
- shared_from_this(),
+ ICE_SHARED_FROM_THIS,
requestId,
batchRequestNum));
}
@@ -311,8 +311,8 @@ CollocatedRequestHandler::invokeAsyncRequest(OutgoingAsyncBase* outAsync, int ba
// dispatched. Otherwise, the handler could be deleted during the dispatch
// if a retry occurs.
//
- CollocatedRequestHandlerPtr self(shared_from_this());
+ CollocatedRequestHandlerPtr self(ICE_SHARED_FROM_THIS);
if(sentAsync(outAsync))
{
invokeAll(outAsync->getOs(), requestId, batchRequestNum);
@@ -433,7 +433,7 @@ CollocatedRequestHandler::sentAsync(OutgoingAsyncBase* outAsync)
{
{
Lock sync(*this);
- if(_sendAsyncRequests.erase(outAsync->shared_from_this()) == 0)
+ if(_sendAsyncRequests.erase(ICE_GET_SHARED_FROM_THIS(outAsync)) == 0)
{
return false; // The request timed-out.
}
diff --git a/cpp/src/Ice/CollocatedRequestHandler.h b/cpp/src/Ice/CollocatedRequestHandler.h
index 3f26d677bb8..5dd33d13eb9 100644
--- a/cpp/src/Ice/CollocatedRequestHandler.h
+++ b/cpp/src/Ice/CollocatedRequestHandler.h
@@ -19,7 +19,6 @@
#include <Ice/ObjectAdapterF.h>
#include <Ice/LoggerF.h>
#include <Ice/TraceLevelsF.h>
-#include <Ice/VirtualShared.h>
namespace Ice
{
@@ -39,8 +38,7 @@ class OutgoingAsync;
class CollocatedRequestHandler : public RequestHandler,
public ResponseHandler,
- private IceUtil::Monitor<IceUtil::Mutex>,
- public Ice::EnableSharedFromThis<CollocatedRequestHandler>
+ private IceUtil::Monitor<IceUtil::Mutex>
{
public:
@@ -73,7 +71,12 @@ public:
void invokeAll(Ice::OutputStream*, Ice::Int, Ice::Int);
- using Ice::EnableSharedFromThis<CollocatedRequestHandler>::shared_from_this;
+#ifdef ICE_CPP11_MAPPING
+ std::shared_ptr<CollocatedRequestHandler> shared_from_this()
+ {
+ return std::static_pointer_cast<CollocatedRequestHandler>(ResponseHandler::shared_from_this());
+ }
+#endif
private:
diff --git a/cpp/src/Ice/CommunicatorI.h b/cpp/src/Ice/CommunicatorI.h
index 83c4661c316..e75037bf72b 100644
--- a/cpp/src/Ice/CommunicatorI.h
+++ b/cpp/src/Ice/CommunicatorI.h
@@ -23,8 +23,11 @@ namespace Ice
class CommunicatorI;
ICE_DEFINE_PTR(CommunicatorIPtr, CommunicatorI);
-class CommunicatorI : public EnableSharedFromThis<CommunicatorI>,
- public Communicator
+class CommunicatorI : public Communicator
+#ifdef ICE_CPP11_MAPPING
+ , public std::enable_shared_from_this<CommunicatorI>
+#endif
+
{
public:
diff --git a/cpp/src/Ice/ConnectRequestHandler.cpp b/cpp/src/Ice/ConnectRequestHandler.cpp
index dc97d999323..55bf01b0e07 100644
--- a/cpp/src/Ice/ConnectRequestHandler.cpp
+++ b/cpp/src/Ice/ConnectRequestHandler.cpp
@@ -43,13 +43,13 @@ ConnectRequestHandler::connect(const Ice::ObjectPrxPtr& proxy)
{
_proxies.insert(proxy);
}
- return _requestHandler ? _requestHandler : shared_from_this();
+ return _requestHandler ? _requestHandler : ICE_SHARED_FROM_THIS;
}
RequestHandlerPtr
ConnectRequestHandler::update(const RequestHandlerPtr& previousHandler, const RequestHandlerPtr& newHandler)
{
- return previousHandler.get() == this ? newHandler : shared_from_this();
+ return previousHandler.get() == this ? newHandler : ICE_SHARED_FROM_THIS;
}
bool
@@ -75,7 +75,7 @@ ConnectRequestHandler::sendAsyncRequest(const ProxyOutgoingAsyncBasePtr& out)
Lock sync(*this);
if(!_initialized)
{
- out->cancelable(shared_from_this()); // This will throw if the request is canceled
+ out->cancelable(ICE_SHARED_FROM_THIS); // This will throw if the request is canceled
}
if(!initialized())
@@ -202,7 +202,7 @@ ConnectRequestHandler::setConnection(const Ice::ConnectionIPtr& connection, bool
// add this proxy to the router info object.
//
RouterInfoPtr ri = _reference->getRouterInfo();
- if(ri && !ri->addProxy(_proxy, AddProxyCallback::shared_from_this()))
+ if(ri && !ri->addProxy(_proxy, ICE_SHARED_FROM_THIS))
{
return; // The request handler will be initialized once addProxy returns.
}
@@ -231,7 +231,7 @@ ConnectRequestHandler::setException(const Ice::LocalException& ex)
//
try
{
- _reference->getInstance()->requestHandlerFactory()->removeRequestHandler(_reference, shared_from_this());
+ _reference->getInstance()->requestHandlerFactory()->removeRequestHandler(_reference, ICE_SHARED_FROM_THIS);
}
catch(const Ice::CommunicatorDestroyedException&)
{
@@ -346,7 +346,7 @@ ConnectRequestHandler::flushRequests()
ICE_SET_EXCEPTION_FROM_CLONE(exception, ex.get()->ice_clone());
// Remove the request handler before retrying.
- _reference->getInstance()->requestHandlerFactory()->removeRequestHandler(_reference, shared_from_this());
+ _reference->getInstance()->requestHandlerFactory()->removeRequestHandler(_reference, ICE_SHARED_FROM_THIS);
if(req.out)
{
@@ -383,7 +383,7 @@ ConnectRequestHandler::flushRequests()
_requestHandler = ICE_MAKE_SHARED(ConnectionRequestHandler, _reference, _connection, _compress);
for(set<Ice::ObjectPrxPtr>::const_iterator p = _proxies.begin(); p != _proxies.end(); ++p)
{
- (*p)->__updateRequestHandler(shared_from_this(), _requestHandler);
+ (*p)->__updateRequestHandler(ICE_SHARED_FROM_THIS, _requestHandler);
}
}
@@ -402,7 +402,7 @@ ConnectRequestHandler::flushRequests()
// Only remove once all the requests are flushed to
// guarantee serialization.
//
- _reference->getInstance()->requestHandlerFactory()->removeRequestHandler(_reference, shared_from_this());
+ _reference->getInstance()->requestHandlerFactory()->removeRequestHandler(_reference, ICE_SHARED_FROM_THIS);
_proxies.clear();
_proxy = ICE_NULLPTR; // Break cyclic reference count.
diff --git a/cpp/src/Ice/ConnectRequestHandler.h b/cpp/src/Ice/ConnectRequestHandler.h
index 222021469f1..bb00a3c5b9b 100644
--- a/cpp/src/Ice/ConnectRequestHandler.h
+++ b/cpp/src/Ice/ConnectRequestHandler.h
@@ -29,8 +29,10 @@ namespace IceInternal
class ConnectRequestHandler : public RequestHandler,
public Reference::GetConnectionCallback,
public RouterInfo::AddProxyCallback,
- public IceUtil::Monitor<IceUtil::Mutex>,
- public Ice::EnableSharedFromThis<ConnectRequestHandler>
+ public IceUtil::Monitor<IceUtil::Mutex>
+#ifdef ICE_CPP11_MAPPING
+ , public std::enable_shared_from_this<ConnectRequestHandler>
+#endif
{
public:
@@ -53,8 +55,6 @@ public:
virtual void addedProxy();
- using Ice::EnableSharedFromThis<ConnectRequestHandler>::shared_from_this;
-
private:
bool initialized();
diff --git a/cpp/src/Ice/ConnectionFactory.cpp b/cpp/src/Ice/ConnectionFactory.cpp
index dbfc20e9a94..87f6edee197 100644
--- a/cpp/src/Ice/ConnectionFactory.cpp
+++ b/cpp/src/Ice/ConnectionFactory.cpp
@@ -867,7 +867,7 @@ IceInternal::OutgoingConnectionFactory::ConnectCallback::connectionStartComplete
}
connection->activate();
- _factory->finishGetConnection(_connectors, *_iter, connection, shared_from_this());
+ _factory->finishGetConnection(_connectors, *_iter, connection, ICE_SHARED_FROM_THIS);
}
void
@@ -979,7 +979,7 @@ IceInternal::OutgoingConnectionFactory::ConnectCallback::getConnection()
// connection.
//
bool compress;
- Ice::ConnectionIPtr connection = _factory->getConnection(_connectors, shared_from_this(), compress);
+ Ice::ConnectionIPtr connection = _factory->getConnection(_connectors, ICE_SHARED_FROM_THIS, compress);
if(!connection)
{
//
@@ -1093,7 +1093,7 @@ IceInternal::OutgoingConnectionFactory::ConnectCallback::removeConnectors(const
void
IceInternal::OutgoingConnectionFactory::ConnectCallback::removeFromPending()
{
- _factory->removeFromPending(shared_from_this(), _connectors);
+ _factory->removeFromPending(ICE_SHARED_FROM_THIS, _connectors);
}
bool
@@ -1427,7 +1427,8 @@ IceInternal::IncomingConnectionFactory::message(ThreadPoolCurrent& current)
}
assert(connection);
- connection->start(shared_from_this());
+
+ connection->start(ICE_SHARED_FROM_THIS);
}
void
@@ -1461,7 +1462,7 @@ IceInternal::IncomingConnectionFactory::finished(ThreadPoolCurrent&, bool close)
#if TARGET_OS_IPHONE != 0
sync.release();
- unregisterForBackgroundNotification(shared_from_this());
+ unregisterForBackgroundNotification(ICE_SHARED_FROM_THIS);
#endif
}
@@ -1581,7 +1582,7 @@ IceInternal::IncomingConnectionFactory::stopAcceptor()
return;
}
- if(_adapter->getThreadPool()->finish(shared_from_this(), true))
+ if(_adapter->getThreadPool()->finish(ICE_SHARED_FROM_THIS, true))
{
_acceptorStarted = false;
closeAcceptor();
@@ -1625,7 +1626,7 @@ IceInternal::IncomingConnectionFactory::initialize()
// start the acceptor if necessary.
//
_acceptorStarted = false;
- registerForBackgroundNotification(shared_from_this());
+ registerForBackgroundNotification(ICE_SHARED_FROM_THIS);
#else
createAcceptor();
#endif
@@ -1681,7 +1682,7 @@ IceInternal::IncomingConnectionFactory::setState(State state)
Trace out(_instance->initializationData().logger, _instance->traceLevels()->networkCat);
out << "accepting " << _endpoint->protocol() << " connections at " << _acceptor->toString();
}
- _adapter->getThreadPool()->_register(shared_from_this(), SocketOperationRead);
+ _adapter->getThreadPool()->_register(ICE_SHARED_FROM_THIS, SocketOperationRead);
}
for_each(_connections.begin(), _connections.end(), Ice::voidMemFun(&ConnectionI::activate));
break;
@@ -1700,7 +1701,7 @@ IceInternal::IncomingConnectionFactory::setState(State state)
Trace out(_instance->initializationData().logger, _instance->traceLevels()->networkCat);
out << "holding " << _endpoint->protocol() << " connections at " << _acceptor->toString();
}
- _adapter->getThreadPool()->unregister(shared_from_this(), SocketOperationRead);
+ _adapter->getThreadPool()->unregister(ICE_SHARED_FROM_THIS, SocketOperationRead);
}
for_each(_connections.begin(), _connections.end(), Ice::voidMemFun(&ConnectionI::hold));
break;
@@ -1717,7 +1718,7 @@ IceInternal::IncomingConnectionFactory::setState(State state)
// the finish() call. Not all selector implementations do support this
// however.
//
- if(_adapter->getThreadPool()->finish(shared_from_this(), true))
+ if(_adapter->getThreadPool()->finish(ICE_SHARED_FROM_THIS, true))
{
closeAcceptor();
}
@@ -1763,10 +1764,10 @@ IceInternal::IncomingConnectionFactory::createAcceptor()
out << "listening for " << _endpoint->protocol() << " connections\n" << _acceptor->toDetailedString();
}
- _adapter->getThreadPool()->initialize(shared_from_this());
+ _adapter->getThreadPool()->initialize(ICE_SHARED_FROM_THIS);
if(_state == StateActive)
{
- _adapter->getThreadPool()->_register(shared_from_this(), SocketOperationRead);
+ _adapter->getThreadPool()->_register(ICE_SHARED_FROM_THIS, SocketOperationRead);
}
}
catch(const Ice::Exception&)
diff --git a/cpp/src/Ice/ConnectionFactory.h b/cpp/src/Ice/ConnectionFactory.h
index 578c728559b..46df6067236 100644
--- a/cpp/src/Ice/ConnectionFactory.h
+++ b/cpp/src/Ice/ConnectionFactory.h
@@ -88,8 +88,11 @@ private:
};
class ConnectCallback : public Ice::ConnectionI::StartCallback,
- public IceInternal::EndpointI_connectors,
- public Ice::EnableSharedFromThis<IceInternal::OutgoingConnectionFactory::ConnectCallback>
+ public IceInternal::EndpointI_connectors
+#ifdef ICE_CPP11_MAPPING
+ , public std::enable_shared_from_this<ConnectCallback>
+#endif
+
{
public:
@@ -171,8 +174,7 @@ private:
class IncomingConnectionFactory : public EventHandler,
public Ice::ConnectionI::StartCallback,
- public IceUtil::Monitor<IceUtil::Mutex>,
- public Ice::EnableSharedFromThis<IncomingConnectionFactory>
+ public IceUtil::Monitor<IceUtil::Mutex>
{
public:
@@ -214,6 +216,14 @@ public:
IncomingConnectionFactory(const InstancePtr&, const EndpointIPtr&, const Ice::ObjectAdapterIPtr&);
void initialize();
virtual ~IncomingConnectionFactory();
+
+#ifdef ICE_CPP11_MAPPING
+ std::shared_ptr<IncomingConnectionFactory> shared_from_this()
+ {
+ return std::static_pointer_cast<IncomingConnectionFactory>(EventHandler::shared_from_this());
+ }
+#endif
+
private:
diff --git a/cpp/src/Ice/ConnectionI.cpp b/cpp/src/Ice/ConnectionI.cpp
index 97d69ed297e..7af8fad5996 100644
--- a/cpp/src/Ice/ConnectionI.cpp
+++ b/cpp/src/Ice/ConnectionI.cpp
@@ -354,7 +354,7 @@ Ice::ConnectionI::start(const StartCallbackPtr& callback)
exception(ex);
if(callback)
{
- callback->connectionStartFailed(shared_from_this(), ex);
+ callback->connectionStartFailed(ICE_SHARED_FROM_THIS, ex);
return;
}
else
@@ -366,7 +366,7 @@ Ice::ConnectionI::start(const StartCallbackPtr& callback)
if(callback)
{
- callback->connectionStartCompleted(shared_from_this());
+ callback->connectionStartCompleted(ICE_SHARED_FROM_THIS);
}
}
@@ -727,7 +727,7 @@ Ice::ConnectionI::sendAsyncRequest(const OutgoingAsyncBasePtr& out, bool compres
// Notify the request that it's cancelable with this connection.
// This will throw if the request is canceled.
//
- out->cancelable(shared_from_this());
+ out->cancelable(ICE_SHARED_FROM_THIS);
Int requestId = 0;
if(response)
{
@@ -816,7 +816,7 @@ Ice::ConnectionI::flushBatchRequestsAsync(::std::function<void(::std::exception_
{
}
};
- auto outAsync = make_shared<ConnectionFlushBatchLambda>(shared_from_this(), _instance, ex, sent);
+ auto outAsync = make_shared<ConnectionFlushBatchLambda>(ICE_SHARED_FROM_THIS, _instance, ex, sent);
outAsync->invoke(__flushBatchRequests_name);
return [outAsync]() { outAsync->cancel(); };
}
@@ -942,9 +942,9 @@ Ice::ConnectionI::setCloseCallback(ICE_IN(ICE_CLOSE_CALLBACK) callback)
const ICE_CLOSE_CALLBACK _callback;
};
#ifdef ICE_CPP11_MAPPING
- _threadPool->dispatch(new CallbackWorkItem(shared_from_this(), move(callback)));
+ _threadPool->dispatch(new CallbackWorkItem(ICE_SHARED_FROM_THIS, move(callback)));
#else
- _threadPool->dispatch(new CallbackWorkItem(shared_from_this(), callback));
+ _threadPool->dispatch(new CallbackWorkItem(ICE_SHARED_FROM_THIS, callback));
#endif
}
}
@@ -960,9 +960,9 @@ Ice::ConnectionI::closeCallback(const ICE_CLOSE_CALLBACK& callback)
try
{
#ifdef ICE_CPP11_MAPPING
- callback(shared_from_this());
+ callback(ICE_SHARED_FROM_THIS);
#else
- callback->closed(shared_from_this());
+ callback->closed(ICE_SHARED_FROM_THIS);
#endif
}
catch(const std::exception& ex)
@@ -990,7 +990,7 @@ Ice::ConnectionI::setACM(const IceUtil::Optional<int>& timeout,
if(_state == StateActive)
{
- _monitor->remove(shared_from_this());
+ _monitor->remove(ICE_SHARED_FROM_THIS);
}
_monitor = _monitor->acm(timeout, close, heartbeat);
@@ -1005,7 +1005,7 @@ Ice::ConnectionI::setACM(const IceUtil::Optional<int>& timeout,
if(_state == StateActive)
{
- _monitor->add(shared_from_this());
+ _monitor->add(ICE_SHARED_FROM_THIS);
}
}
@@ -1384,7 +1384,7 @@ Ice::ConnectionI::createProxy(const Identity& ident) const
// reference.
//
return _instance->proxyFactory()->referenceToProxy(
- _instance->referenceFactory()->create(ident, shared_from_this()));
+ _instance->referenceFactory()->create(ident, ICE_SHARED_FROM_CONST_THIS(ConnectionI)));
}
#if defined(ICE_USE_IOCP) || defined(ICE_OS_WINRT)
@@ -1633,7 +1633,7 @@ Ice::ConnectionI::message(ThreadPoolCurrent& current)
// satisfied before continuing.
//
scheduleTimeout(newOp);
- _threadPool->update(shared_from_this(), current.operation, newOp);
+ _threadPool->update(ICE_SHARED_FROM_THIS, current.operation, newOp);
return;
}
@@ -1647,7 +1647,7 @@ Ice::ConnectionI::message(ThreadPoolCurrent& current)
return;
}
- _threadPool->unregister(shared_from_this(), current.operation);
+ _threadPool->unregister(ICE_SHARED_FROM_THIS, current.operation);
//
// We start out in holding state.
@@ -1695,7 +1695,7 @@ Ice::ConnectionI::message(ThreadPoolCurrent& current)
if(_state < StateClosed)
{
scheduleTimeout(newOp);
- _threadPool->update(shared_from_this(), current.operation, newOp);
+ _threadPool->update(ICE_SHARED_FROM_THIS, current.operation, newOp);
}
}
@@ -1757,7 +1757,7 @@ Ice::ConnectionI::message(ThreadPoolCurrent& current)
}
else
{
- _threadPool->dispatchFromThisThread(new DispatchCall(shared_from_this(), startCB, sentCBs, compress, requestId,
+ _threadPool->dispatchFromThisThread(new DispatchCall(ICE_SHARED_FROM_THIS, startCB, sentCBs, compress, requestId,
invokeNum, servantManager, adapter, outAsync,
heartbeatCallback, current.stream));
@@ -1778,7 +1778,7 @@ ConnectionI::dispatch(const StartCallbackPtr& startCB, const vector<OutgoingMess
//
if(startCB)
{
- startCB->connectionStartCompleted(shared_from_this());
+ startCB->connectionStartCompleted(ICE_SHARED_FROM_THIS);
++dispatchedCount;
}
@@ -1824,9 +1824,9 @@ ConnectionI::dispatch(const StartCallbackPtr& startCB, const vector<OutgoingMess
try
{
#ifdef ICE_CPP11_MAPPING
- heartbeatCallback(shared_from_this());
+ heartbeatCallback(ICE_SHARED_FROM_THIS);
#else
- heartbeatCallback->heartbeat(shared_from_this());
+ heartbeatCallback->heartbeat(ICE_SHARED_FROM_THIS);
#endif
}
catch(const std::exception& ex)
@@ -1919,7 +1919,7 @@ Ice::ConnectionI::finished(ThreadPoolCurrent& current, bool close)
}
else
{
- _threadPool->dispatchFromThisThread(new FinishCall(shared_from_this(), close));
+ _threadPool->dispatchFromThisThread(new FinishCall(ICE_SHARED_FROM_THIS, close));
}
}
@@ -1972,7 +1972,7 @@ Ice::ConnectionI::finish(bool close)
{
assert(_exception);
- _startCallback->connectionStartFailed(shared_from_this(), *_exception);
+ _startCallback->connectionStartFailed(ICE_SHARED_FROM_THIS, *_exception);
_startCallback = 0;
}
@@ -2358,7 +2358,7 @@ Ice::ConnectionI::setState(State state)
{
return;
}
- _threadPool->_register(shared_from_this(), SocketOperationRead);
+ _threadPool->_register(ICE_SHARED_FROM_THIS, SocketOperationRead);
break;
}
@@ -2374,7 +2374,7 @@ Ice::ConnectionI::setState(State state)
}
if(_state == StateActive)
{
- _threadPool->unregister(shared_from_this(), SocketOperationRead);
+ _threadPool->unregister(ICE_SHARED_FROM_THIS, SocketOperationRead);
}
break;
}
@@ -2405,7 +2405,7 @@ Ice::ConnectionI::setState(State state)
// Don't need to close now for connections so only close the transceiver
// if the selector request it.
//
- if(_threadPool->finish(shared_from_this(), false))
+ if(_threadPool->finish(ICE_SHARED_FROM_THIS, false))
{
_transceiver->close();
}
@@ -2440,11 +2440,11 @@ Ice::ConnectionI::setState(State state)
{
_acmLastActivity = IceUtil::Time::now(IceUtil::Time::Monotonic);
}
- _monitor->add(shared_from_this());
+ _monitor->add(ICE_SHARED_FROM_THIS);
}
else if(_state == StateActive)
{
- _monitor->remove(shared_from_this());
+ _monitor->remove(ICE_SHARED_FROM_THIS);
}
}
@@ -2529,7 +2529,7 @@ Ice::ConnectionI::initiateShutdown()
if(op)
{
scheduleTimeout(op);
- _threadPool->_register(shared_from_this(), op);
+ _threadPool->_register(ICE_SHARED_FROM_THIS, op);
}
}
}
@@ -2573,7 +2573,7 @@ Ice::ConnectionI::initialize(SocketOperation operation)
if(s != SocketOperationNone)
{
scheduleTimeout(s);
- _threadPool->update(shared_from_this(), operation, s);
+ _threadPool->update(ICE_SHARED_FROM_THIS, operation, s);
return false;
}
@@ -2619,7 +2619,7 @@ Ice::ConnectionI::validate(SocketOperation operation)
if(op)
{
scheduleTimeout(op);
- _threadPool->update(shared_from_this(), operation, op);
+ _threadPool->update(ICE_SHARED_FROM_THIS, operation, op);
return false;
}
}
@@ -2648,7 +2648,7 @@ Ice::ConnectionI::validate(SocketOperation operation)
if(op)
{
scheduleTimeout(op);
- _threadPool->update(shared_from_this(), operation, op);
+ _threadPool->update(ICE_SHARED_FROM_THIS, operation, op);
return false;
}
}
@@ -3026,7 +3026,7 @@ Ice::ConnectionI::sendMessage(OutgoingMessage& message)
_writeStream.swap(*_sendStreams.back().stream);
scheduleTimeout(op);
- _threadPool->_register(shared_from_this(), op);
+ _threadPool->_register(ICE_SHARED_FROM_THIS, op);
return AsyncStatusQueued;
}
@@ -3647,7 +3647,7 @@ ConnectionI::reap()
{
if(_monitor)
{
- _monitor->reap(shared_from_this());
+ _monitor->reap(ICE_SHARED_FROM_THIS);
}
if(_observer)
{
diff --git a/cpp/src/Ice/ConnectionI.h b/cpp/src/Ice/ConnectionI.h
index a0a6cae89a1..72d239e48c1 100644
--- a/cpp/src/Ice/ConnectionI.h
+++ b/cpp/src/Ice/ConnectionI.h
@@ -38,7 +38,6 @@
#include <Ice/ConnectionAsync.h>
#include <Ice/BatchRequestQueueF.h>
#include <Ice/ACM.h>
-#include <Ice/VirtualShared.h>
#include <Ice/OutputStream.h>
#include <Ice/InputStream.h>
@@ -69,8 +68,7 @@ class ConnectionI : public Connection,
public IceInternal::EventHandler,
public IceInternal::ResponseHandler,
public IceInternal::CancellationHandler,
- public IceUtil::Monitor<IceUtil::Mutex>,
- public EnableSharedFromThis<ConnectionI>
+ public IceUtil::Monitor<IceUtil::Mutex>
{
class Observer : public IceInternal::ObserverHelperT<Ice::Instrumentation::ConnectionObserver>
{
@@ -93,6 +91,13 @@ class ConnectionI : public Connection,
public:
+#ifdef ICE_CPP11_MAPPING
+ std::shared_ptr<ConnectionI> shared_from_this()
+ {
+ return std::dynamic_pointer_cast<ConnectionI>(VirtualEnableSharedFromThisBase::shared_from_this());
+ }
+#endif
+
struct OutgoingMessage
{
OutgoingMessage(Ice::OutputStream* str, bool comp) :
@@ -260,8 +265,6 @@ public:
virtual ~ConnectionI();
- using EnableSharedFromThis<ConnectionI>::shared_from_this;
-
private:
ConnectionI(const Ice::CommunicatorPtr&, const IceInternal::InstancePtr&, const IceInternal::ACMMonitorPtr&,
diff --git a/cpp/src/Ice/ConnectionRequestHandler.h b/cpp/src/Ice/ConnectionRequestHandler.h
index 1a2129275b4..90838f7d3f4 100644
--- a/cpp/src/Ice/ConnectionRequestHandler.h
+++ b/cpp/src/Ice/ConnectionRequestHandler.h
@@ -13,13 +13,14 @@
#include <Ice/RequestHandler.h>
#include <Ice/ReferenceF.h>
#include <Ice/ProxyF.h>
-#include <Ice/VirtualShared.h>
namespace IceInternal
{
-class ConnectionRequestHandler : public RequestHandler,
- public Ice::EnableSharedFromThis<ConnectionRequestHandler>
+class ConnectionRequestHandler : public RequestHandler
+#ifdef ICE_CPP11_MAPPING
+ , public std::enable_shared_from_this<ConnectionRequestHandler>
+#endif
{
public:
diff --git a/cpp/src/Ice/EndpointI.h b/cpp/src/Ice/EndpointI.h
index 1dd10708142..3e692be0081 100644
--- a/cpp/src/Ice/EndpointI.h
+++ b/cpp/src/Ice/EndpointI.h
@@ -16,7 +16,6 @@
#include <Ice/TransceiverF.h>
#include <Ice/ConnectorF.h>
#include <Ice/AcceptorF.h>
-#include <Ice/VirtualShared.h>
namespace Ice
{
@@ -29,7 +28,10 @@ class InputStream;
namespace IceInternal
{
-class ICE_API EndpointI_connectors : public virtual ICE_SHARED
+class ICE_API EndpointI_connectors
+#ifndef ICE_CPP11_MAPPING
+ : public virtual IceUtil::Shared
+#endif
{
public:
@@ -39,7 +41,7 @@ public:
virtual void exception(const Ice::LocalException&) = 0;
};
-class ICE_API EndpointI : public Ice::Endpoint, public virtual ICE_SHARED
+class ICE_API EndpointI : public Ice::Endpoint
{
public:
diff --git a/cpp/src/Ice/EventHandler.h b/cpp/src/Ice/EventHandler.h
index ced022ed06a..e7124182d76 100644
--- a/cpp/src/Ice/EventHandler.h
+++ b/cpp/src/Ice/EventHandler.h
@@ -22,9 +22,9 @@ namespace IceInternal
class ICE_API EventHandler :
#ifdef ICE_CPP11_MAPPING
- public virtual Ice::VirtualEnableSharedFromThisBase
+ public EnableSharedFromThis<EventHandler>
#else
- public virtual Ice::LocalObject
+ public virtual Ice::LocalObject
#endif
{
public:
diff --git a/cpp/src/Ice/IPEndpointI.cpp b/cpp/src/Ice/IPEndpointI.cpp
index 21f4def1c2d..10983ccc672 100644
--- a/cpp/src/Ice/IPEndpointI.cpp
+++ b/cpp/src/Ice/IPEndpointI.cpp
@@ -81,7 +81,7 @@ IceInternal::IPEndpointInfoI::secure() const
Ice::EndpointInfoPtr
IceInternal::IPEndpointI::getInfo() const
{
- Ice::IPEndpointInfoPtr info = ICE_MAKE_SHARED(IPEndpointInfoI, shared_from_this());
+ Ice::IPEndpointInfoPtr info = ICE_MAKE_SHARED(IPEndpointInfoI, ICE_SHARED_FROM_CONST_THIS(IPEndpointI));
fillEndpointInfo(info.get());
return info;
}
@@ -123,7 +123,7 @@ IceInternal::IPEndpointI::connectionId(const string& connectionId) const
{
if(connectionId == _connectionId)
{
- return shared_from_this();
+ return ICE_SHARED_FROM_CONST_THIS(IPEndpointI);
}
else
{
@@ -134,7 +134,7 @@ IceInternal::IPEndpointI::connectionId(const string& connectionId) const
void
IceInternal::IPEndpointI::connectors_async(Ice::EndpointSelectionType selType, const EndpointI_connectorsPtr& cb) const
{
- _instance->resolve(_host, _port, selType, shared_from_this(), cb);
+ _instance->resolve(_host, _port, selType, ICE_SHARED_FROM_CONST_THIS(IPEndpointI), cb);
}
vector<EndpointIPtr>
@@ -144,7 +144,7 @@ IceInternal::IPEndpointI::expand() const
vector<string> hosts = getHostsForEndpointExpand(_host, _instance->protocolSupport(), false);
if(hosts.empty())
{
- endps.push_back(shared_from_this());
+ endps.push_back(ICE_SHARED_FROM_CONST_THIS(IPEndpointI));
}
else
{
diff --git a/cpp/src/Ice/IPEndpointI.h b/cpp/src/Ice/IPEndpointI.h
index a2ed7984037..7378792a7c7 100644
--- a/cpp/src/Ice/IPEndpointI.h
+++ b/cpp/src/Ice/IPEndpointI.h
@@ -43,7 +43,10 @@ private:
const EndpointIPtr _endpoint;
};
-class ICE_API IPEndpointI : public EndpointI, public Ice::EnableSharedFromThis<IPEndpointI>
+class ICE_API IPEndpointI : public EndpointI
+#ifdef ICE_CPP11_MAPPING
+ , public std::enable_shared_from_this<IPEndpointI>
+#endif
{
public:
diff --git a/cpp/src/Ice/Incoming.cpp b/cpp/src/Ice/Incoming.cpp
index 5bd91cb36c3..d100160b573 100644
--- a/cpp/src/Ice/Incoming.cpp
+++ b/cpp/src/Ice/Incoming.cpp
@@ -48,7 +48,7 @@ IceInternal::IncomingBase::IncomingBase(Instance* instance, ResponseHandler* res
_current.adapter = adapter;
#ifdef ICE_CPP11_MAPPING
::Ice::ConnectionI* conn = dynamic_cast<::Ice::ConnectionI*>(connection);
- _current.con = conn ? dynamic_pointer_cast<::Ice::ConnectionI>(conn->shared_from_this()) : nullptr;
+ _current.con = conn ? conn->shared_from_this() : nullptr;
#else
_current.con = connection;
#endif
diff --git a/cpp/src/Ice/IncomingAsync.cpp b/cpp/src/Ice/IncomingAsync.cpp
index d6a8059bba7..7c9f248ed89 100644
--- a/cpp/src/Ice/IncomingAsync.cpp
+++ b/cpp/src/Ice/IncomingAsync.cpp
@@ -66,7 +66,7 @@ Init init;
IceInternal::IncomingAsync::IncomingAsync(Incoming& in) :
IncomingBase(in),
_instanceCopy(_os.instance()),
- _responseHandlerCopy(_responseHandler->shared_from_this()), // Acquire reference on response handler
+ _responseHandlerCopy(ICE_GET_SHARED_FROM_THIS(_responseHandler)), // Acquire reference on response handler
_retriable(in.isRetriable()),
_active(true)
{
diff --git a/cpp/src/Ice/LoggerAdminI.cpp b/cpp/src/Ice/LoggerAdminI.cpp
index 4f193c91903..34fef69a9e8 100644
--- a/cpp/src/Ice/LoggerAdminI.cpp
+++ b/cpp/src/Ice/LoggerAdminI.cpp
@@ -27,7 +27,10 @@ namespace
const char* traceCategory = "Admin.Logger";
-class LoggerAdminI : public Ice::LoggerAdmin, public Ice::EnableSharedFromThis<LoggerAdminI>
+class LoggerAdminI : public Ice::LoggerAdmin
+#ifdef ICE_CPP11_MAPPING
+ , public std::enable_shared_from_this<LoggerAdminI>
+#endif
{
public:
@@ -138,7 +141,11 @@ public:
typedef IceUtil::Handle<Job> JobPtr;
-class LoggerAdminLoggerI : public Ice::EnableSharedFromThis<LoggerAdminLoggerI>, public IceInternal::LoggerAdminLogger
+class LoggerAdminLoggerI : public IceInternal::LoggerAdminLogger
+#ifdef ICE_CPP11_MAPPING
+ , public std::enable_shared_from_this<LoggerAdminLoggerI>
+#endif
+
{
public:
diff --git a/cpp/src/Ice/ObjectAdapterFactory.h b/cpp/src/Ice/ObjectAdapterFactory.h
index 7b0c053c0a5..93a6aede7df 100644
--- a/cpp/src/Ice/ObjectAdapterFactory.h
+++ b/cpp/src/Ice/ObjectAdapterFactory.h
@@ -19,8 +19,12 @@
namespace IceInternal
{
-class ObjectAdapterFactory : public Ice::EnableSharedFromThis<ObjectAdapterFactory>,
- public ::IceUtil::Monitor< ::IceUtil::RecMutex>
+class ObjectAdapterFactory : public ::IceUtil::Monitor< ::IceUtil::RecMutex>,
+#ifdef ICE_CPP11_MAPPING
+ public std::enable_shared_from_this<ObjectAdapterFactory>
+#else
+ public virtual IceUtil::Shared
+#endif
{
public:
diff --git a/cpp/src/Ice/ObjectAdapterI.h b/cpp/src/Ice/ObjectAdapterI.h
index 503facf1102..b37af859e2e 100644
--- a/cpp/src/Ice/ObjectAdapterI.h
+++ b/cpp/src/Ice/ObjectAdapterI.h
@@ -38,9 +38,12 @@ namespace Ice
class ObjectAdapterI;
ICE_DEFINE_PTR(ObjectAdapterIPtr, ObjectAdapterI);
-class ObjectAdapterI : public EnableSharedFromThis<ObjectAdapterI>,
- public ObjectAdapter,
+class ObjectAdapterI : public ObjectAdapter,
public IceUtil::Monitor<IceUtil::RecMutex>
+#ifdef ICE_CPP11_MAPPING
+ , public std::enable_shared_from_this<ObjectAdapterI>
+#endif
+
{
public:
diff --git a/cpp/src/Ice/OpaqueEndpointI.cpp b/cpp/src/Ice/OpaqueEndpointI.cpp
index d6c8bdbf984..2be3b400dcb 100644
--- a/cpp/src/Ice/OpaqueEndpointI.cpp
+++ b/cpp/src/Ice/OpaqueEndpointI.cpp
@@ -132,7 +132,7 @@ IceInternal::OpaqueEndpointI::timeout() const
EndpointIPtr
IceInternal::OpaqueEndpointI::timeout(Int) const
{
- return shared_from_this();
+ return ICE_SHARED_FROM_CONST_THIS(OpaqueEndpointI);
}
const string&
@@ -144,7 +144,7 @@ IceInternal::OpaqueEndpointI::connectionId() const
EndpointIPtr
IceInternal::OpaqueEndpointI::connectionId(const string&) const
{
- return shared_from_this();
+ return ICE_SHARED_FROM_CONST_THIS(OpaqueEndpointI);
}
bool
@@ -156,7 +156,7 @@ IceInternal::OpaqueEndpointI::compress() const
EndpointIPtr
IceInternal::OpaqueEndpointI::compress(bool) const
{
- return shared_from_this();
+ return ICE_SHARED_FROM_CONST_THIS(OpaqueEndpointI);
}
bool
@@ -193,7 +193,7 @@ vector<EndpointIPtr>
IceInternal::OpaqueEndpointI::expand() const
{
vector<EndpointIPtr> endps;
- endps.push_back(shared_from_this());
+ endps.push_back(ICE_SHARED_FROM_CONST_THIS(OpaqueEndpointI));
return endps;
}
diff --git a/cpp/src/Ice/OpaqueEndpointI.h b/cpp/src/Ice/OpaqueEndpointI.h
index a0ebae3a49f..d1eaffa6f1f 100644
--- a/cpp/src/Ice/OpaqueEndpointI.h
+++ b/cpp/src/Ice/OpaqueEndpointI.h
@@ -16,7 +16,10 @@
namespace IceInternal
{
-class OpaqueEndpointI : public EndpointI, public Ice::EnableSharedFromThis<OpaqueEndpointI>
+class OpaqueEndpointI : public EndpointI
+#ifdef ICE_CPP11_MAPPING
+ , public std::enable_shared_from_this<OpaqueEndpointI>
+#endif
{
public:
diff --git a/cpp/src/Ice/OutgoingAsync.cpp b/cpp/src/Ice/OutgoingAsync.cpp
index e43acc7b521..e9261214a07 100644
--- a/cpp/src/Ice/OutgoingAsync.cpp
+++ b/cpp/src/Ice/OutgoingAsync.cpp
@@ -93,7 +93,7 @@ OutgoingAsyncBase::invokeSentAsync()
//
try
{
- _instance->clientThreadPool()->dispatch(new AsynchronousSent(_cachedConnection, shared_from_this()));
+ _instance->clientThreadPool()->dispatch(new AsynchronousSent(_cachedConnection, ICE_SHARED_FROM_THIS));
}
catch(const Ice::CommunicatorDestroyedException&)
{
@@ -127,7 +127,7 @@ OutgoingAsyncBase::invokeExceptionAsync()
// CommunicatorDestroyedCompleted is the only exception that can propagate directly
// from this method.
//
- _instance->clientThreadPool()->dispatch(new AsynchronousException(_cachedConnection, shared_from_this()));
+ _instance->clientThreadPool()->dispatch(new AsynchronousException(_cachedConnection, ICE_SHARED_FROM_THIS));
}
void
@@ -157,7 +157,7 @@ OutgoingAsyncBase::invokeResponseAsync()
// CommunicatorDestroyedCompleted is the only exception that can propagate directly
// from this method.
//
- _instance->clientThreadPool()->dispatch(new AsynchronousResponse(_cachedConnection, shared_from_this()));
+ _instance->clientThreadPool()->dispatch(new AsynchronousResponse(_cachedConnection, ICE_SHARED_FROM_THIS));
}
void
@@ -380,7 +380,7 @@ OutgoingAsyncBase::cancel(const Ice::LocalException& ex)
}
handler = _cancellationHandler;
}
- handler->asyncRequestCanceled(shared_from_this(), ex);
+ handler->asyncRequestCanceled(ICE_SHARED_FROM_THIS, ex);
}
#ifndef ICE_CPP11_MAPPING
@@ -576,7 +576,7 @@ ProxyOutgoingAsyncBase::exception(const Exception& exc)
_cachedConnection = 0;
if(_proxy->__reference()->getInvocationTimeout() == -2)
{
- _instance->timer()->cancel(shared_from_this());
+ _instance->timer()->cancel(ICE_SHARED_FROM_THIS);
}
//
@@ -590,7 +590,7 @@ ProxyOutgoingAsyncBase::exception(const Exception& exc)
// the retry interval is 0. This method can be called with the
// connection locked so we can't just retry here.
//
- _instance->retryQueue()->add(shared_from_this(), _proxy->__handleException(exc, _handler, _mode, _sent, _cnt));
+ _instance->retryQueue()->add(ICE_SHARED_FROM_THIS, _proxy->__handleException(exc, _handler, _mode, _sent, _cnt));
return false;
}
catch(const Exception& ex)
@@ -607,7 +607,7 @@ ProxyOutgoingAsyncBase::cancelable(const CancellationHandlerPtr& handler)
const int timeout = _cachedConnection->timeout();
if(timeout > 0)
{
- _instance->timer()->schedule(shared_from_this(), IceUtil::Time::milliSeconds(timeout));
+ _instance->timer()->schedule(ICE_SHARED_FROM_THIS, IceUtil::Time::milliSeconds(timeout));
}
}
OutgoingAsyncBase::cancelable(handler);
@@ -625,7 +625,7 @@ ProxyOutgoingAsyncBase::retryException(const Exception& ex)
// connection to be done.
//
_proxy->__updateRequestHandler(_handler, 0); // Clear request handler and always retry.
- _instance->retryQueue()->add(shared_from_this(), 0);
+ _instance->retryQueue()->add(ICE_SHARED_FROM_THIS, 0);
}
catch(const Ice::Exception& exc)
{
@@ -699,7 +699,7 @@ ProxyOutgoingAsyncBase::invokeImpl(bool userThread)
int invocationTimeout = _proxy->__reference()->getInvocationTimeout();
if(invocationTimeout > 0)
{
- _instance->timer()->schedule(shared_from_this(), IceUtil::Time::milliSeconds(invocationTimeout));
+ _instance->timer()->schedule(ICE_SHARED_FROM_THIS, IceUtil::Time::milliSeconds(invocationTimeout));
}
}
else
@@ -713,7 +713,7 @@ ProxyOutgoingAsyncBase::invokeImpl(bool userThread)
{
_sent = false;
_handler = _proxy->__getRequestHandler();
- AsyncStatus status = _handler->sendAsyncRequest(shared_from_this());
+ AsyncStatus status = _handler->sendAsyncRequest(ICE_SHARED_FROM_THIS);
if(status & AsyncStatusSent)
{
if(userThread)
@@ -748,7 +748,7 @@ ProxyOutgoingAsyncBase::invokeImpl(bool userThread)
int interval = _proxy->__handleException(ex, _handler, _mode, _sent, _cnt);
if(interval > 0)
{
- _instance->retryQueue()->add(shared_from_this(), interval);
+ _instance->retryQueue()->add(ICE_SHARED_FROM_THIS, interval);
return;
}
else
@@ -783,7 +783,7 @@ ProxyOutgoingAsyncBase::sentImpl(bool done)
{
if(_proxy->__reference()->getInvocationTimeout() != -1)
{
- _instance->timer()->cancel(shared_from_this());
+ _instance->timer()->cancel(ICE_SHARED_FROM_THIS);
}
}
return OutgoingAsyncBase::sentImpl(done);
@@ -794,7 +794,7 @@ ProxyOutgoingAsyncBase::exceptionImpl(const Exception& ex)
{
if(_proxy->__reference()->getInvocationTimeout() != -1)
{
- _instance->timer()->cancel(shared_from_this());
+ _instance->timer()->cancel(ICE_SHARED_FROM_THIS);
}
return OutgoingAsyncBase::exceptionImpl(ex);
}
@@ -804,7 +804,7 @@ ProxyOutgoingAsyncBase::responseImpl(bool ok)
{
if(_proxy->__reference()->getInvocationTimeout() != -1)
{
- _instance->timer()->cancel(shared_from_this());
+ _instance->timer()->cancel(ICE_SHARED_FROM_THIS);
}
return OutgoingAsyncBase::responseImpl(ok);
}
@@ -1056,7 +1056,7 @@ AsyncStatus
OutgoingAsync::invokeRemote(const ConnectionIPtr& connection, bool compress, bool response)
{
_cachedConnection = connection;
- return connection->sendAsyncRequest(shared_from_this(), compress, response, 0);
+ return connection->sendAsyncRequest(ICE_SHARED_FROM_THIS, compress, response, 0);
}
AsyncStatus
@@ -1171,7 +1171,7 @@ ProxyFlushBatchAsync::invokeRemote(const ConnectionIPtr& connection, bool compre
}
}
_cachedConnection = connection;
- return connection->sendAsyncRequest(shared_from_this(), compress, false, _batchRequestNum);
+ return connection->sendAsyncRequest(ICE_SHARED_FROM_THIS, compress, false, _batchRequestNum);
}
AsyncStatus
@@ -1261,7 +1261,7 @@ ConnectionFlushBatchAsync::invoke(const string& operation)
}
else
{
- status = _connection->sendAsyncRequest(shared_from_this(), false, false, batchRequestNum);
+ status = _connection->sendAsyncRequest(ICE_SHARED_FROM_THIS, false, false, batchRequestNum);
}
if(status & AsyncStatusSent)
@@ -1385,7 +1385,7 @@ CommunicatorFlushBatchAsync::flushConnection(const ConnectionIPtr& con)
try
{
- OutgoingAsyncBasePtr flushBatch = ICE_MAKE_SHARED(FlushBatch, shared_from_this(), _instance, _observer);
+ OutgoingAsyncBasePtr flushBatch = ICE_MAKE_SHARED(FlushBatch, ICE_SHARED_FROM_THIS, _instance, _observer);
int batchRequestNum = con->getBatchRequestQueue()->swap(flushBatch->getOs());
if(batchRequestNum == 0)
{
@@ -1407,8 +1407,8 @@ void
CommunicatorFlushBatchAsync::invoke(const string& operation)
{
_observer.attach(_instance.get(), operation);
- _instance->outgoingConnectionFactory()->flushAsyncBatchRequests(shared_from_this());
- _instance->objectAdapterFactory()->flushAsyncBatchRequests(shared_from_this());
+ _instance->outgoingConnectionFactory()->flushAsyncBatchRequests(ICE_SHARED_FROM_THIS);
+ _instance->objectAdapterFactory()->flushAsyncBatchRequests(ICE_SHARED_FROM_THIS);
check(true);
}
diff --git a/cpp/src/Ice/ResponseHandler.h b/cpp/src/Ice/ResponseHandler.h
index 502af9c556d..9a1cbbaeb71 100644
--- a/cpp/src/Ice/ResponseHandler.h
+++ b/cpp/src/Ice/ResponseHandler.h
@@ -28,7 +28,12 @@ class OutputStream;
namespace IceInternal
{
-class ResponseHandler : public Ice::EnableSharedFromThis<ResponseHandler>
+class ResponseHandler :
+#ifdef ICE_CPP11_MAPPING
+ public EnableSharedFromThis<ResponseHandler>
+#else
+ public virtual IceUtil::Shared
+#endif
{
public:
diff --git a/cpp/src/Ice/RetryQueue.h b/cpp/src/Ice/RetryQueue.h
index ad19fc6d75f..bc2dd744786 100644
--- a/cpp/src/Ice/RetryQueue.h
+++ b/cpp/src/Ice/RetryQueue.h
@@ -17,14 +17,15 @@
#include <Ice/OutgoingAsyncF.h>
#include <Ice/InstanceF.h>
#include <Ice/RequestHandler.h> // For CancellationHandler
-#include <Ice/VirtualShared.h>
namespace IceInternal
{
class RetryTask : public IceUtil::TimerTask,
- public CancellationHandler,
- public Ice::EnableSharedFromThis<RetryTask>
+ public CancellationHandler
+#ifdef ICE_CPP11_MAPPING
+ , public std::enable_shared_from_this<RetryTask>
+#endif
{
public:
diff --git a/cpp/src/Ice/RouterInfo.h b/cpp/src/Ice/RouterInfo.h
index a7e632a5951..298cbc455f4 100644
--- a/cpp/src/Ice/RouterInfo.h
+++ b/cpp/src/Ice/RouterInfo.h
@@ -19,7 +19,6 @@
#include <Ice/BuiltinSequences.h>
#include <Ice/Identity.h>
#include <Ice/Comparable.h>
-#include <Ice/VirtualShared.h>
#include <set>
@@ -68,7 +67,10 @@ public:
};
typedef IceUtil::Handle<GetClientEndpointsCallback> GetClientEndpointsCallbackPtr;
- class AddProxyCallback : public Ice::EnableSharedFromThis<AddProxyCallback>
+ class AddProxyCallback
+#ifndef ICE_CPP11_MAPPING
+ : public virtual IceUtil::Shared
+#endif
{
public:
diff --git a/cpp/src/Ice/Selector.cpp b/cpp/src/Ice/Selector.cpp
index bc35aff816f..808b7fe8620 100644
--- a/cpp/src/Ice/Selector.cpp
+++ b/cpp/src/Ice/Selector.cpp
@@ -77,11 +77,8 @@ Selector::initialize(EventHandler* handler)
}
handler->getNativeInfo()->initialize(_handle, reinterpret_cast<ULONG_PTR>(handler));
#else
-# ifdef ICE_CPP11_MAPPING
- EventHandlerPtr h = dynamic_pointer_cast<EventHandler>(handler->shared_from_this());
-# else
- EventHandlerPtr h = handler;
-# endif
+ EventHandlerPtr h = ICE_GET_SHARED_FROM_THIS(handler);
+
handler->getNativeInfo()->setCompletedHandler(
ref new SocketOperationCompletedHandler(
[=](int operation)
@@ -232,7 +229,7 @@ Selector::completed(EventHandler* handler, SocketOperation op)
}
#else
IceUtil::Monitor<IceUtil::Mutex>::Lock lock(_monitor);
- _events.push_back(SelectEvent(std::dynamic_pointer_cast<EventHandler>(handler->shared_from_this()), op));
+ _events.push_back(SelectEvent(handler->shared_from_this(), op));
_monitor.notify();
#endif
}
@@ -726,12 +723,8 @@ Selector::finishSelect(vector<pair<EventHandler*, SocketOperation> >& handlers)
continue; // Interrupted
}
-#ifdef ICE_CPP11_MAPPING
- map<EventHandlerPtr, SocketOperation>::iterator q = _readyHandlers.find(
- dynamic_pointer_cast<EventHandler>(p.first->shared_from_this()));
-#else
- map<EventHandlerPtr, SocketOperation>::iterator q = _readyHandlers.find(p.first);
-#endif
+ map<EventHandlerPtr, SocketOperation>::iterator q = _readyHandlers.find(ICE_GET_SHARED_FROM_THIS(p.first));
+
if(q != _readyHandlers.end()) // Handler will be added by the loop below
{
q->second = p.second; // We just remember which operations are ready here.
@@ -841,22 +834,14 @@ Selector::checkReady(EventHandler* handler)
{
if(handler->_ready & ~handler->_disabled & handler->_registered)
{
-#ifdef ICE_CPP11_MAPPING
- _readyHandlers.insert(make_pair(dynamic_pointer_cast<EventHandler>(handler->shared_from_this()),
- SocketOperationNone));
-#else
- _readyHandlers.insert(make_pair(handler, SocketOperationNone));
-#endif
+ _readyHandlers.insert(make_pair(ICE_GET_SHARED_FROM_THIS(handler), SocketOperationNone));
+
wakeup();
}
else
{
-#ifdef ICE_CPP11_MAPPING
- map<EventHandlerPtr, SocketOperation>::iterator p =
- _readyHandlers.find(dynamic_pointer_cast<EventHandler>(handler->shared_from_this()));
-#else
- map<EventHandlerPtr, SocketOperation>::iterator p = _readyHandlers.find(handler);
-#endif
+ map<EventHandlerPtr, SocketOperation>::iterator p = _readyHandlers.find(ICE_GET_SHARED_FROM_THIS(handler));
+
if(p != _readyHandlers.end())
{
_readyHandlers.erase(p);
@@ -1037,11 +1022,7 @@ toCFCallbacks(SocketOperation op)
}
EventHandlerWrapper::EventHandlerWrapper(EventHandler* handler, Selector& selector) :
-#ifdef ICE_CPP11_MAPPING
- _handler(std::dynamic_pointer_cast<EventHandler>(handler->shared_from_this())),
-#else
- _handler(handler),
-#endif
+ _handler(ICE_GET_SHARED_FROM_THIS(handler)),
_streamNativeInfo(StreamNativeInfoPtr::dynamicCast(handler->getNativeInfo())),
_selector(selector),
_ready(SocketOperationNone),
diff --git a/cpp/src/Ice/TcpEndpointI.cpp b/cpp/src/Ice/TcpEndpointI.cpp
index 2b2e26e924e..9be649213fd 100644
--- a/cpp/src/Ice/TcpEndpointI.cpp
+++ b/cpp/src/Ice/TcpEndpointI.cpp
@@ -73,7 +73,7 @@ IceInternal::TcpEndpointI::streamWriteImpl(OutputStream* s) const
EndpointInfoPtr
IceInternal::TcpEndpointI::getInfo() const
{
- TCPEndpointInfoPtr info = ICE_MAKE_SHARED(InfoI<Ice::TCPEndpointInfo>, shared_from_this());
+ TCPEndpointInfoPtr info = ICE_MAKE_SHARED(InfoI<Ice::TCPEndpointInfo>, ICE_SHARED_FROM_CONST_THIS(TcpEndpointI));
fillEndpointInfo(info.get());
return info;
}
@@ -89,7 +89,7 @@ IceInternal::TcpEndpointI::timeout(Int timeout) const
{
if(timeout == _timeout)
{
- return shared_from_this();
+ return ICE_SHARED_FROM_CONST_THIS(TcpEndpointI);
}
else
{
@@ -108,7 +108,7 @@ IceInternal::TcpEndpointI::compress(bool compress) const
{
if(compress == _compress)
{
- return shared_from_this();
+ return ICE_SHARED_FROM_CONST_THIS(TcpEndpointI);
}
else
{
@@ -131,7 +131,7 @@ IceInternal::TcpEndpointI::transceiver() const
AcceptorPtr
IceInternal::TcpEndpointI::acceptor(const string&) const
{
- return new TcpAcceptor(ICE_DYNAMIC_CAST(TcpEndpointI, shared_from_this()), _instance, _host, _port);
+ return new TcpAcceptor(ICE_DYNAMIC_CAST(TcpEndpointI, ICE_SHARED_FROM_CONST_THIS(TcpEndpointI)), _instance, _host, _port);
}
TcpEndpointIPtr
diff --git a/cpp/src/Ice/TcpEndpointI.h b/cpp/src/Ice/TcpEndpointI.h
index f40c5c14713..d85e8f01996 100644
--- a/cpp/src/Ice/TcpEndpointI.h
+++ b/cpp/src/Ice/TcpEndpointI.h
@@ -18,7 +18,7 @@
namespace IceInternal
{
-class TcpEndpointI : public IPEndpointI, public Ice::EnableSharedFromThis<TcpEndpointI>
+class TcpEndpointI : public IPEndpointI
{
public:
@@ -51,7 +51,6 @@ public:
TcpEndpointIPtr endpoint(const TcpAcceptorPtr&) const;
using IPEndpointI::connectionId;
- using Ice::EnableSharedFromThis<TcpEndpointI>::shared_from_this;
protected:
diff --git a/cpp/src/Ice/ThreadPool.cpp b/cpp/src/Ice/ThreadPool.cpp
index 4e9a5735835..87e3db78a23 100644
--- a/cpp/src/Ice/ThreadPool.cpp
+++ b/cpp/src/Ice/ThreadPool.cpp
@@ -692,11 +692,7 @@ IceInternal::ThreadPool::run(const EventHandlerThreadPtr& thread)
if(_nextHandler != _handlers.end())
{
current._ioCompleted = false;
-#ifdef ICE_CPP11_MAPPING
- current._handler = dynamic_pointer_cast<EventHandler>(_nextHandler->first->shared_from_this());
-#else
- current._handler = _nextHandler->first;
-#endif
+ current._handler = ICE_GET_SHARED_FROM_THIS(_nextHandler->first);
current.operation = _nextHandler->second;
++_nextHandler;
thread->setState(ThreadStateInUseForIO);
@@ -748,20 +744,10 @@ IceInternal::ThreadPool::run(const EventHandlerThreadPtr& thread)
{
current._ioCompleted = false;
#ifdef ICE_OS_WINRT
-# ifdef ICE_CPP11_MAPPING
- current._handler = dynamic_pointer_cast<EventHandler>(
- _selector.getNextHandler(current.operation, _threadIdleTime)->shared_from_this());
-# else
- current._handler = _selector.getNextHandler(current.operation, _threadIdleTime);
-# endif
+ current._handler = ICE_GET_SHARED_FROM_THIS(_selector.getNextHandler(current.operation, _threadIdleTime));
#else
-# ifdef ICE_CPP11_MAPPING
- current._handler = dynamic_pointer_cast<EventHandler>(_selector.getNextHandler(current.operation,
- current._count, current._error, _threadIdleTime)->shared_from_this());
-# else
- current._handler = _selector.getNextHandler(current.operation, current._count, current._error,
- _threadIdleTime);
-# endif
+ current._handler = ICE_GET_SHARED_FROM_THIS(_selector.getNextHandler(current.operation, current._count, current._error,
+ _threadIdleTime));
#endif
}
catch(const SelectorTimeoutException&)
@@ -808,20 +794,11 @@ IceInternal::ThreadPool::run(const EventHandlerThreadPtr& thread)
try
{
#ifdef ICE_OS_WINRT
-# ifdef ICE_CPP11_MAPPING
- current._handler = dynamic_pointer_cast<EventHandler>(_selector.getNextHandler(
- current.operation, _serverIdleTime)->shared_from_this());
-# else
- current._handler = _selector.getNextHandler(current.operation, _serverIdleTime);
-# endif
+ current._handler = ICE_GET_SHARED_FROM_THIS(_selector.getNextHandler(current.operation, _serverIdleTime));
#else
-# ifdef ICE_CPP11_MAPPING
- current._handler = dynamic_pointer_cast<EventHandler>(_selector.getNextHandler(current.operation,
- current._count, current._error, _serverIdleTime)->shared_from_this());
-# else
- current._handler = _selector.getNextHandler(current.operation, current._count, current._error,
- _serverIdleTime);
-# endif
+
+ current._handler = ICE_GET_SHARED_FROM_THIS(_selector.getNextHandler(current.operation, current._count,
+ current._error, _serverIdleTime));
#endif
}
catch(const SelectorTimeoutException&)
diff --git a/cpp/src/Ice/UdpEndpointI.cpp b/cpp/src/Ice/UdpEndpointI.cpp
index 2adf5dc32cc..25a47b955d9 100644
--- a/cpp/src/Ice/UdpEndpointI.cpp
+++ b/cpp/src/Ice/UdpEndpointI.cpp
@@ -94,7 +94,7 @@ EndpointInfoPtr
IceInternal::UdpEndpointI::getInfo() const
{
Ice::UDPEndpointInfoPtr info = ICE_MAKE_SHARED(InfoI<Ice::UDPEndpointInfo>,
- ICE_DYNAMIC_CAST(UdpEndpointI, shared_from_this()));
+ ICE_DYNAMIC_CAST(UdpEndpointI, ICE_SHARED_FROM_CONST_THIS(UdpEndpointI)));
fillEndpointInfo(info.get());
return info;
}
@@ -108,7 +108,7 @@ IceInternal::UdpEndpointI::timeout() const
EndpointIPtr
IceInternal::UdpEndpointI::timeout(Int) const
{
- return shared_from_this();
+ return ICE_SHARED_FROM_CONST_THIS(UdpEndpointI);
}
bool
@@ -122,7 +122,7 @@ IceInternal::UdpEndpointI::compress(bool compress) const
{
if(compress == _compress)
{
- return shared_from_this();
+ return ICE_SHARED_FROM_CONST_THIS(UdpEndpointI);
}
else
{
@@ -140,7 +140,7 @@ IceInternal::UdpEndpointI::datagram() const
TransceiverPtr
IceInternal::UdpEndpointI::transceiver() const
{
- return new UdpTransceiver(ICE_DYNAMIC_CAST(UdpEndpointI, shared_from_this()), _instance, _host, _port, _mcastInterface, _connect);
+ return new UdpTransceiver(ICE_DYNAMIC_CAST(UdpEndpointI, ICE_SHARED_FROM_CONST_THIS(UdpEndpointI)), _instance, _host, _port, _mcastInterface, _connect);
}
AcceptorPtr
diff --git a/cpp/src/Ice/ValueFactoryManagerI.h b/cpp/src/Ice/ValueFactoryManagerI.h
index d69ffcfba57..3659171aeaa 100644
--- a/cpp/src/Ice/ValueFactoryManagerI.h
+++ b/cpp/src/Ice/ValueFactoryManagerI.h
@@ -11,7 +11,6 @@
#define ICE_VALUE_FACTORY_MANAGER_I_H
#include <Ice/ValueFactory.h>
-#include <Ice/VirtualShared.h>
#include <IceUtil/Mutex.h>
namespace IceInternal
@@ -20,8 +19,7 @@ namespace IceInternal
class ValueFactoryManagerI;
ICE_DEFINE_PTR(ValueFactoryManagerIPtr, ValueFactoryManagerI);
-class ValueFactoryManagerI : public Ice::EnableSharedFromThis<ValueFactoryManagerI>,
- public Ice::ValueFactoryManager,
+class ValueFactoryManagerI : public Ice::ValueFactoryManager,
public IceUtil::Mutex
{
public:
diff --git a/cpp/src/Ice/VirtualShared.h b/cpp/src/Ice/VirtualShared.h
new file mode 100644
index 00000000000..1e01c9c28d2
--- /dev/null
+++ b/cpp/src/Ice/VirtualShared.h
@@ -0,0 +1,43 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2016 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
+
+#ifndef ICE_VIRTUAL_SHARED_H
+#define ICE_VIRTUAL_SHARED_H
+
+#ifdef ICE_CPP11_MAPPING
+
+namespace IceInternal
+{
+
+class VirtualEnableSharedFromThisBase : public std::enable_shared_from_this<VirtualEnableSharedFromThisBase>
+{
+public:
+
+ virtual ~VirtualEnableSharedFromThisBase() = default;
+};
+
+template<typename T>
+class EnableSharedFromThis : public virtual VirtualEnableSharedFromThisBase
+{
+public:
+
+ std::shared_ptr<T> shared_from_this()
+ {
+ return std::dynamic_pointer_cast<T>(VirtualEnableSharedFromThisBase::shared_from_this());
+ }
+
+ std::shared_ptr<T const> shared_from_this() const
+ {
+ return std::dynamic_pointer_cast<T const>(VirtualEnableSharedFromThisBase::shared_from_this());
+ }
+};
+
+}
+#endif
+#endif
diff --git a/cpp/src/Ice/WSEndpoint.cpp b/cpp/src/Ice/WSEndpoint.cpp
index 48a9ede3c37..244017087a2 100644
--- a/cpp/src/Ice/WSEndpoint.cpp
+++ b/cpp/src/Ice/WSEndpoint.cpp
@@ -70,7 +70,7 @@ IceInternal::WSEndpoint::WSEndpoint(const ProtocolInstancePtr& instance, const E
Ice::EndpointInfoPtr
IceInternal::WSEndpoint::getInfo() const
{
- WSEndpointInfoPtr info = ICE_MAKE_SHARED(InfoI<Ice::WSEndpointInfo>, shared_from_this());
+ WSEndpointInfoPtr info = ICE_MAKE_SHARED(InfoI<Ice::WSEndpointInfo>, ICE_SHARED_FROM_CONST_THIS(WSEndpoint));
info->underlying = _delegate->getInfo();
info->compress = info->underlying->compress;
info->timeout = info->underlying->timeout;
@@ -108,7 +108,7 @@ IceInternal::WSEndpoint::timeout(Int timeout) const
{
if(timeout == _delegate->timeout())
{
- return shared_from_this();
+ return ICE_SHARED_FROM_CONST_THIS(WSEndpoint);
}
else
{
@@ -127,7 +127,7 @@ IceInternal::WSEndpoint::connectionId(const string& connectionId) const
{
if(connectionId == _delegate->connectionId())
{
- return shared_from_this();
+ return ICE_SHARED_FROM_CONST_THIS(WSEndpoint);
}
else
{
@@ -146,7 +146,7 @@ IceInternal::WSEndpoint::compress(bool compress) const
{
if(compress == _delegate->compress())
{
- return shared_from_this();
+ return ICE_SHARED_FROM_CONST_THIS(WSEndpoint);
}
else
{
@@ -222,7 +222,7 @@ AcceptorPtr
IceInternal::WSEndpoint::acceptor(const string& adapterName) const
{
AcceptorPtr delAcc = _delegate->acceptor(adapterName);
- return new WSAcceptor(shared_from_this(), _instance, delAcc);
+ return new WSAcceptor(ICE_SHARED_FROM_CONST_THIS(WSEndpoint), _instance, delAcc);
}
WSEndpointPtr
@@ -237,7 +237,7 @@ IceInternal::WSEndpoint::expand() const
vector<EndpointIPtr> endps = _delegate->expand();
for(vector<EndpointIPtr>::iterator p = endps.begin(); p != endps.end(); ++p)
{
- *p = p->get() == _delegate.get() ? shared_from_this() : ICE_MAKE_SHARED(WSEndpoint, _instance, *p, _resource);
+ *p = p->get() == _delegate.get() ? ICE_SHARED_FROM_CONST_THIS(WSEndpoint) : ICE_MAKE_SHARED(WSEndpoint, _instance, *p, _resource);
}
return endps;
}
diff --git a/cpp/src/Ice/WSEndpoint.h b/cpp/src/Ice/WSEndpoint.h
index a247219409d..5b0a3fa3aa4 100644
--- a/cpp/src/Ice/WSEndpoint.h
+++ b/cpp/src/Ice/WSEndpoint.h
@@ -20,7 +20,10 @@
namespace IceInternal
{
-class WSEndpoint : public EndpointI, public Ice::EnableSharedFromThis<WSEndpoint>
+class WSEndpoint : public EndpointI
+#ifdef ICE_CPP11_MAPPING
+ , public std::enable_shared_from_this<WSEndpoint>
+#endif
{
public:
diff --git a/cpp/src/Ice/ios/StreamEndpointI.cpp b/cpp/src/Ice/ios/StreamEndpointI.cpp
index 78e8dab2cff..676210ee493 100644
--- a/cpp/src/Ice/ios/StreamEndpointI.cpp
+++ b/cpp/src/Ice/ios/StreamEndpointI.cpp
@@ -159,7 +159,7 @@ IceObjC::StreamEndpointI::StreamEndpointI(const InstancePtr& instance, Ice::Inpu
EndpointInfoPtr
IceObjC::StreamEndpointI::getInfo() const
{
- TCPEndpointInfoPtr info = ICE_MAKE_SHARED(InfoI<Ice::TCPEndpointInfo>, shared_from_this());
+ TCPEndpointInfoPtr info = ICE_MAKE_SHARED(InfoI<Ice::TCPEndpointInfo>, ICE_SHARED_FROM_CONST_THIS(StreamEndpointI));
IPEndpointI::fillEndpointInfo(info.get());
info->timeout = _timeout;
info->compress = _compress;
@@ -177,7 +177,7 @@ IceObjC::StreamEndpointI::timeout(Int t) const
{
if(t == _timeout)
{
- return shared_from_this();
+ return ICE_SHARED_FROM_CONST_THIS(StreamEndpointI);
}
else
{
@@ -196,7 +196,7 @@ IceObjC::StreamEndpointI::compress(bool c) const
{
if(c == _compress)
{
- return shared_from_this();
+ return ICE_SHARED_FROM_CONST_THIS(StreamEndpointI);
}
else
{
@@ -233,7 +233,7 @@ IceObjC::StreamEndpointI::transceiver() const
AcceptorPtr
IceObjC::StreamEndpointI::acceptor(const string&) const
{
- return new StreamAcceptor(shared_from_this(), _instance, _host, _port);
+ return new StreamAcceptor(ICE_SHARED_FROM_CONST_THIS(StreamEndpointI), _instance, _host, _port);
}
IceObjC::StreamEndpointIPtr
diff --git a/cpp/src/Ice/ios/StreamEndpointI.h b/cpp/src/Ice/ios/StreamEndpointI.h
index 3dd90551199..974bb4b8b74 100644
--- a/cpp/src/Ice/ios/StreamEndpointI.h
+++ b/cpp/src/Ice/ios/StreamEndpointI.h
@@ -65,13 +65,9 @@ class StreamAcceptor;
typedef IceUtil::Handle<StreamAcceptor> StreamAcceptorPtr;
class StreamEndpointI;
-#ifdef ICE_CPP11_MAPPING // C++11 mapping
-typedef ::std::shared_ptr<StreamEndpointI> StreamEndpointIPtr;
-#else
-typedef IceUtil::Handle<StreamEndpointI> StreamEndpointIPtr;
-#endif
+ICE_DEFINE_PTR(StreamEndpointIPtr, StreamEndpointI);
-class StreamEndpointI : public IceInternal::IPEndpointI, public Ice::EnableSharedFromThis<StreamEndpointI>
+class StreamEndpointI : public IceInternal::IPEndpointI
{
public:
@@ -95,6 +91,12 @@ public:
virtual std::string options() const;
#ifdef ICE_CPP11_MAPPING
+
+ std::shared_ptr<StreamEndpointI> shared_from_this()
+ {
+ return std::static_pointer_cast<StreamEndpointI>(IceInternal::IPEndpointI::shared_from_this());
+ }
+
virtual bool operator==(const Ice::Endpoint&) const;
virtual bool operator<(const Ice::Endpoint&) const;
#else
@@ -105,7 +107,6 @@ public:
StreamEndpointIPtr endpoint(const StreamAcceptorPtr&) const;
using IPEndpointI::connectionId;
- using Ice::EnableSharedFromThis<StreamEndpointI>::shared_from_this;
protected:
diff --git a/cpp/src/IceBT/EndpointI.cpp b/cpp/src/IceBT/EndpointI.cpp
index 332d669cace..32d0c22aa50 100644
--- a/cpp/src/IceBT/EndpointI.cpp
+++ b/cpp/src/IceBT/EndpointI.cpp
@@ -126,7 +126,7 @@ IceBT::EndpointI::timeout(Int timeout) const
{
if(timeout == _timeout)
{
- return shared_from_this();
+ return ICE_SHARED_FROM_CONST_THIS(EndpointI);
}
else
{
@@ -145,7 +145,7 @@ IceBT::EndpointI::connectionId(const string& connectionId) const
{
if(connectionId == _connectionId)
{
- return shared_from_this();
+ return ICE_SHARED_FROM_CONST_THIS(EndpointI);
}
else
{
@@ -164,7 +164,7 @@ IceBT::EndpointI::compress(bool compress) const
{
if(compress == _compress)
{
- return shared_from_this();
+ return ICE_SHARED_FROM_CONST_THIS(EndpointI);
}
else
{
@@ -205,7 +205,7 @@ IceBT::EndpointI::connectors_async(EndpointSelectionType selType, const IceInter
ostr << "searching for service " << _uuid << " at " << _addr;
_instance->logger()->trace(_instance->traceCategory(), ostr.str());
}
- _instance->engine()->findService(_addr, _uuid, new FindCallbackI(shared_from_this(), selType));
+ _instance->engine()->findService(_addr, _uuid, new FindCallbackI(ICE_SHARED_FROM_CONST_THIS(EndpointI), selType));
}
const_cast<vector<IceInternal::EndpointI_connectorsPtr>&>(_callbacks).push_back(cb);
@@ -214,7 +214,7 @@ IceBT::EndpointI::connectors_async(EndpointSelectionType selType, const IceInter
IceInternal::AcceptorPtr
IceBT::EndpointI::acceptor(const string& adapterName) const
{
- return new AcceptorI(shared_from_this(), _instance, adapterName, _addr, _uuid, _name, _channel);
+ return new AcceptorI(ICE_SHARED_FROM_CONST_THIS(EndpointI), _instance, adapterName, _addr, _uuid, _name, _channel);
}
vector<IceInternal::EndpointIPtr>
@@ -224,7 +224,7 @@ IceBT::EndpointI::expand() const
// Nothing to do here.
//
vector<IceInternal::EndpointIPtr> endps;
- endps.push_back(shared_from_this());
+ endps.push_back(ICE_SHARED_FROM_CONST_THIS(EndpointI));
return endps;
}
@@ -452,7 +452,7 @@ IceBT::EndpointI::options() const
Ice::EndpointInfoPtr
IceBT::EndpointI::getInfo() const
{
- EndpointInfoPtr info = ICE_MAKE_SHARED(EndpointInfoI, shared_from_this());
+ EndpointInfoPtr info = ICE_MAKE_SHARED(EndpointInfoI, ICE_SHARED_FROM_CONST_THIS(EndpointI));
info->addr = _addr;
info->uuid = _uuid;
return info;
diff --git a/cpp/src/IceBT/EndpointI.h b/cpp/src/IceBT/EndpointI.h
index f0d2433d122..ad537fd1461 100644
--- a/cpp/src/IceBT/EndpointI.h
+++ b/cpp/src/IceBT/EndpointI.h
@@ -21,7 +21,10 @@
namespace IceBT
{
-class EndpointI : public IceInternal::EndpointI, public Ice::EnableSharedFromThis<EndpointI>
+class EndpointI : public IceInternal::EndpointI
+#ifdef ICE_CPP11_MAPPING
+ , public std::enable_shared_from_this<EndpointI>
+#endif
{
public:
diff --git a/cpp/src/IceBox/ServiceManagerI.cpp b/cpp/src/IceBox/ServiceManagerI.cpp
index ed4af718a91..c767df5552f 100644
--- a/cpp/src/IceBox/ServiceManagerI.cpp
+++ b/cpp/src/IceBox/ServiceManagerI.cpp
@@ -918,7 +918,7 @@ IceBox::ServiceManagerI::stopAll()
function<void(exception_ptr)>
IceBox::ServiceManagerI::makeObserverCompletedCallback(const shared_ptr<ServiceObserverPrx>& observer)
{
- auto self = weak_from_this();
+ weak_ptr<ServiceManagerI> self = shared_from_this();
return [self, observer](exception_ptr ex)
{
auto s = self.lock();
diff --git a/cpp/src/IceBox/ServiceManagerI.h b/cpp/src/IceBox/ServiceManagerI.h
index 7107056e509..85a115d7b5f 100644
--- a/cpp/src/IceBox/ServiceManagerI.h
+++ b/cpp/src/IceBox/ServiceManagerI.h
@@ -20,8 +20,10 @@ namespace IceBox
{
class ServiceManagerI : public ServiceManager,
- public IceUtil::Monitor<IceUtil::Mutex>,
- public Ice::EnableSharedFromThis<ServiceManagerI>
+ public IceUtil::Monitor<IceUtil::Mutex>
+#ifdef ICE_CPP11_MAPPING
+ , public std::enable_shared_from_this<ServiceManagerI>
+#endif
{
public:
diff --git a/cpp/src/IceDiscovery/LookupI.cpp b/cpp/src/IceDiscovery/LookupI.cpp
index 7c5e3bc6371..dace9a6fc12 100644
--- a/cpp/src/IceDiscovery/LookupI.cpp
+++ b/cpp/src/IceDiscovery/LookupI.cpp
@@ -117,7 +117,7 @@ AdapterRequest::finished(const Ice::ObjectPrxPtr& proxy)
void
AdapterRequest::runTimerTask()
{
- _lookup->adapterRequestTimedOut(shared_from_this());
+ _lookup->adapterRequestTimedOut(ICE_SHARED_FROM_THIS);
}
void
@@ -129,7 +129,7 @@ ObjectRequest::response(const Ice::ObjectPrxPtr& proxy)
void
ObjectRequest::runTimerTask()
{
- _lookup->objectRequestTimedOut(shared_from_this());
+ _lookup->objectRequestTimedOut(ICE_SHARED_FROM_THIS);
}
LookupI::LookupI(const LocatorRegistryIPtr& registry, const LookupPrxPtr& lookup, const Ice::PropertiesPtr& properties) :
diff --git a/cpp/src/IceDiscovery/LookupI.h b/cpp/src/IceDiscovery/LookupI.h
index 1432d7f0ff7..7da188ebfad 100644
--- a/cpp/src/IceDiscovery/LookupI.h
+++ b/cpp/src/IceDiscovery/LookupI.h
@@ -15,7 +15,6 @@
#include <IceUtil/Timer.h>
#include <Ice/Properties.h>
-#include <Ice/VirtualShared.h>
namespace IceDiscovery
{
@@ -68,7 +67,7 @@ protected:
std::vector<std::function<void(const std::shared_ptr<::Ice::ObjectPrx>&)>> _callbacks;
};
-class ObjectRequest : public Request<Ice::Identity>, public Ice::EnableSharedFromThis<ObjectRequest>
+class ObjectRequest : public Request<Ice::Identity>, public std::enable_shared_from_this<ObjectRequest>
{
public:
@@ -85,7 +84,7 @@ private:
};
typedef std::shared_ptr<ObjectRequest> ObjectRequestPtr;
-class AdapterRequest : public Request<std::string>, public Ice::EnableSharedFromThis<AdapterRequest>
+class AdapterRequest : public Request<std::string>, public std::enable_shared_from_this<AdapterRequest>
{
public:
@@ -159,8 +158,7 @@ protected:
std::vector<CB> _callbacks;
};
-class ObjectRequest : public RequestT<Ice::Identity, Ice::AMD_Locator_findObjectByIdPtr>,
- public Ice::EnableSharedFromThis<ObjectRequest>
+class ObjectRequest : public RequestT<Ice::Identity, Ice::AMD_Locator_findObjectByIdPtr>
{
public:
@@ -177,7 +175,7 @@ private:
};
typedef IceUtil::Handle<ObjectRequest> ObjectRequestPtr;
-class AdapterRequest : public RequestT<std::string, Ice::AMD_Locator_findAdapterByIdPtr>, public Ice::EnableSharedFromThis<AdapterRequest>
+class AdapterRequest : public RequestT<std::string, Ice::AMD_Locator_findAdapterByIdPtr>
{
public:
@@ -204,8 +202,10 @@ typedef IceUtil::Handle<AdapterRequest> AdapterRequestPtr;
#endif
class LookupI : public Lookup,
- private IceUtil::Mutex,
- public Ice::EnableSharedFromThis<LookupI>
+ private IceUtil::Mutex
+#ifdef ICE_CPP11_MAPPING
+ , public std::enable_shared_from_this<LookupI>
+#endif
{
public:
diff --git a/cpp/src/IceIAP/EndpointI.h b/cpp/src/IceIAP/EndpointI.h
index c4016073453..149c719ac22 100644
--- a/cpp/src/IceIAP/EndpointI.h
+++ b/cpp/src/IceIAP/EndpointI.h
@@ -24,7 +24,10 @@ typedef ::std::shared_ptr<iAPEndpointI> iAPEndpointIPtr;
typedef IceUtil::Handle<iAPEndpointI> iAPEndpointIPtr;
#endif
-class iAPEndpointI : public IceInternal::EndpointI, public Ice::EnableSharedFromThis<iAPEndpointI>
+class iAPEndpointI : public IceInternal::EndpointI
+#ifdef ICE_CPP11_MAPPING
+ , public std::enable_shared_from_this<iAPEndpointI>
+#endif
{
public:
diff --git a/cpp/src/IceIAP/EndpointI.mm b/cpp/src/IceIAP/EndpointI.mm
index 44a0526d9ab..95605579c91 100644
--- a/cpp/src/IceIAP/EndpointI.mm
+++ b/cpp/src/IceIAP/EndpointI.mm
@@ -137,7 +137,7 @@ IceObjC::iAPEndpointI::streamWriteImpl(OutputStream* s) const
EndpointInfoPtr
IceObjC::iAPEndpointI::getInfo() const
{
- IceIAP::EndpointInfoPtr info = ICE_MAKE_SHARED(InfoI<IceIAP::EndpointInfo>, shared_from_this());
+ IceIAP::EndpointInfoPtr info = ICE_MAKE_SHARED(InfoI<IceIAP::EndpointInfo>, ICE_SHARED_FROM_CONST_THIS(iAPEndpointI));
info->timeout = _timeout;
info->compress = _compress;
info->manufacturer = _manufacturer;
@@ -182,7 +182,7 @@ IceObjC::iAPEndpointI::timeout(Int t) const
{
if(t == _timeout)
{
- return shared_from_this();
+ return ICE_SHARED_FROM_CONST_THIS(iAPEndpointI);
}
else
{
@@ -202,7 +202,7 @@ IceObjC::iAPEndpointI::connectionId(const string& cId) const
{
if(cId == _connectionId)
{
- return shared_from_this();
+ return ICE_SHARED_FROM_CONST_THIS(iAPEndpointI);
}
else
{
@@ -222,7 +222,7 @@ IceObjC::iAPEndpointI::compress(bool c) const
{
if(c == _compress)
{
- return shared_from_this();
+ return ICE_SHARED_FROM_CONST_THIS(iAPEndpointI);
}
else
{
@@ -303,7 +303,7 @@ vector<EndpointIPtr>
IceObjC::iAPEndpointI::expand() const
{
vector<EndpointIPtr> endps;
- endps.push_back(shared_from_this());
+ endps.push_back(ICE_SHARED_FROM_CONST_THIS(iAPEndpointI));
return endps;
}
diff --git a/cpp/src/IceLocatorDiscovery/PluginI.cpp b/cpp/src/IceLocatorDiscovery/PluginI.cpp
index 2ee4a752d09..3e63ec6a681 100644
--- a/cpp/src/IceLocatorDiscovery/PluginI.cpp
+++ b/cpp/src/IceLocatorDiscovery/PluginI.cpp
@@ -58,7 +58,12 @@ namespace
class LocatorI; // Forward declaration
-class Request : public Ice::EnableSharedFromThis<Request>
+class Request :
+#ifdef ICE_CPP11_MAPPING
+ public std::enable_shared_from_this<Request>
+#else
+ public virtual IceUtil::Shared
+#endif
{
public:
@@ -124,8 +129,10 @@ ICE_DEFINE_PTR(RequestPtr, Request);
class LocatorI : public Ice::BlobjectArrayAsync,
public IceUtil::TimerTask,
- private IceUtil::Monitor<IceUtil::Mutex>,
- public Ice::EnableSharedFromThis<LocatorI>
+ private IceUtil::Monitor<IceUtil::Mutex>
+#ifdef ICE_CPP11_MAPPING
+ , public std::enable_shared_from_this<LocatorI>
+#endif
{
public:
@@ -533,7 +540,7 @@ Request::exception(const Ice::Exception& ex)
catch(const Ice::Exception&)
{
_exception.reset(ex.ice_clone());
- _locator->invoke(_locatorPrx, shared_from_this()); // Retry with new locator proxy
+ _locator->invoke(_locatorPrx, this); // Retry with new locator proxy
}
#endif
}
@@ -613,7 +620,7 @@ LocatorI::foundLocator(const Ice::LocatorPrxPtr& locator)
if(_pendingRetryCount > 0) // No need to retry, we found a locator.
{
- _timer->cancel(shared_from_this());
+ _timer->cancel(ICE_SHARED_FROM_THIS);
_pendingRetryCount = 0;
}
@@ -693,7 +700,7 @@ LocatorI::invoke(const Ice::LocatorPrxPtr& locator, const RequestPtr& request)
#else
_lookup->begin_findLocator(_instanceName, _lookupReply); // Send multicast request.
#endif
- _timer->schedule(shared_from_this(), _timeout);
+ _timer->schedule(ICE_SHARED_FROM_THIS, _timeout);
}
catch(const Ice::LocalException&)
{
@@ -721,7 +728,7 @@ LocatorI::runTimerTask()
#else
_lookup->begin_findLocator(_instanceName, _lookupReply); // Send multicast request.
#endif
- _timer->schedule(shared_from_this(), _timeout);
+ _timer->schedule(ICE_SHARED_FROM_THIS, _timeout);
return;
}
catch(const Ice::LocalException&)
diff --git a/cpp/src/IceSSL/Certificate.cpp b/cpp/src/IceSSL/Certificate.cpp
index 92374649035..f1025e83c16 100755
--- a/cpp/src/IceSSL/Certificate.cpp
+++ b/cpp/src/IceSSL/Certificate.cpp
@@ -1198,11 +1198,11 @@ Certificate::getPublicKey() const
{
throw CertificateEncodingException(__FILE__, __LINE__, errorToString(err));
}
- return ICE_MAKE_SHARED(PublicKey, shared_from_this(), key);
+ return ICE_MAKE_SHARED(PublicKey, ICE_SHARED_FROM_CONST_THIS(Certificate), key);
#elif defined(ICE_USE_SCHANNEL)
- return ICE_MAKE_SHARED(PublicKey, shared_from_this(), &_certInfo->SubjectPublicKeyInfo);
+ return ICE_MAKE_SHARED(PublicKey, ICE_SHARED_FROM_CONST_THIS(Certificate), &_certInfo->SubjectPublicKeyInfo);
#elif defined(ICE_USE_OPENSSL)
- return ICE_MAKE_SHARED(PublicKey, shared_from_this(), X509_get_pubkey(_cert));
+ return ICE_MAKE_SHARED(PublicKey, ICE_SHARED_FROM_CONST_THIS(Certificate), X509_get_pubkey(_cert));
#elif defined(ICE_OS_WINRT)
return ICE_NULLPTR; // Not supported
#else
diff --git a/cpp/src/IceSSL/EndpointI.cpp b/cpp/src/IceSSL/EndpointI.cpp
index 1615b12d05d..08b78b1317a 100644
--- a/cpp/src/IceSSL/EndpointI.cpp
+++ b/cpp/src/IceSSL/EndpointI.cpp
@@ -60,7 +60,7 @@ IceSSL::EndpointI::streamWriteImpl(Ice::OutputStream* stream) const
Ice::EndpointInfoPtr
IceSSL::EndpointI::getInfo() const
{
- EndpointInfoPtr info = ICE_MAKE_SHARED(IceInternal::InfoI<EndpointInfo>, shared_from_this());
+ EndpointInfoPtr info = ICE_MAKE_SHARED(IceInternal::InfoI<EndpointInfo>, ICE_SHARED_FROM_CONST_THIS(EndpointI));
info->underlying = _delegate->getInfo();
info->compress = info->underlying->compress;
info->timeout = info->underlying->timeout;
@@ -90,7 +90,7 @@ IceSSL::EndpointI::timeout(Int timeout) const
{
if(timeout == _delegate->timeout())
{
- return shared_from_this();
+ return ICE_SHARED_FROM_CONST_THIS(EndpointI);
}
else
{
@@ -109,7 +109,7 @@ IceSSL::EndpointI::connectionId(const string& connectionId) const
{
if(connectionId == _delegate->connectionId())
{
- return shared_from_this();
+ return ICE_SHARED_FROM_CONST_THIS(EndpointI);
}
else
{
@@ -128,7 +128,7 @@ IceSSL::EndpointI::compress(bool compress) const
{
if(compress == _delegate->compress())
{
- return shared_from_this();
+ return ICE_SHARED_FROM_CONST_THIS(EndpointI);
}
else
{
@@ -197,7 +197,7 @@ IceSSL::EndpointI::connectors_async(Ice::EndpointSelectionType selType,
IceInternal::AcceptorPtr
IceSSL::EndpointI::acceptor(const string& adapterName) const
{
- return new AcceptorI(shared_from_this(), _instance, _delegate->acceptor(adapterName), adapterName);
+ return new AcceptorI(ICE_SHARED_FROM_CONST_THIS(EndpointI), _instance, _delegate->acceptor(adapterName), adapterName);
}
EndpointIPtr
@@ -212,7 +212,7 @@ IceSSL::EndpointI::expand() const
vector<IceInternal::EndpointIPtr> endps = _delegate->expand();
for(vector<IceInternal::EndpointIPtr>::iterator p = endps.begin(); p != endps.end(); ++p)
{
- *p = p->get() == _delegate.get() ? shared_from_this() : ICE_MAKE_SHARED(EndpointI, _instance, *p);
+ *p = p->get() == _delegate.get() ? ICE_SHARED_FROM_CONST_THIS(EndpointI) : ICE_MAKE_SHARED(EndpointI, _instance, *p);
}
return endps;
}
diff --git a/cpp/src/IceSSL/EndpointI.h b/cpp/src/IceSSL/EndpointI.h
index fd122d7b146..4876a32e640 100644
--- a/cpp/src/IceSSL/EndpointI.h
+++ b/cpp/src/IceSSL/EndpointI.h
@@ -20,7 +20,10 @@
namespace IceSSL
{
-class EndpointI : public IceInternal::EndpointI, public Ice::EnableSharedFromThis<EndpointI>
+class EndpointI : public IceInternal::EndpointI
+#ifdef ICE_CPP11_MAPPING
+ , public std::enable_shared_from_this<EndpointI>
+#endif
{
public:
diff --git a/cpp/src/IceSSL/uwp/EndpointI.cpp b/cpp/src/IceSSL/uwp/EndpointI.cpp
index 846bcab6d23..9e1af78995f 100644
--- a/cpp/src/IceSSL/uwp/EndpointI.cpp
+++ b/cpp/src/IceSSL/uwp/EndpointI.cpp
@@ -83,11 +83,11 @@ IceSSL::EndpointI::getInfo() const
IPEndpointInfoPtr info;
if(_instance->secure())
{
- info = ICE_MAKE_SHARED(IceInternal::InfoI<IceSSL::EndpointInfo>, shared_from_this());
+ info = ICE_MAKE_SHARED(IceInternal::InfoI<IceSSL::EndpointInfo>, ICE_SHARED_FROM_CONST_THIS(EndpointI));
}
else
{
- info = ICE_MAKE_SHARED(IceInternal::InfoI<Ice::TCPEndpointInfo>, shared_from_this());
+ info = ICE_MAKE_SHARED(IceInternal::InfoI<Ice::TCPEndpointInfo>, ICE_SHARED_FROM_CONST_THIS(EndpointI));
}
fillEndpointInfo(info.get());
return info;
@@ -97,7 +97,7 @@ Ice::EndpointInfoPtr
IceSSL::EndpointI::getWSInfo(const string& resource) const
{
IPEndpointInfoPtr info;
- IceSSL::WSSEndpointInfoPtr i = ICE_MAKE_SHARED(IceInternal::InfoI<IceSSL::WSSEndpointInfo>, shared_from_this());
+ IceSSL::WSSEndpointInfoPtr i = ICE_MAKE_SHARED(IceInternal::InfoI<IceSSL::WSSEndpointInfo>, ICE_SHARED_FROM_CONST_THIS(EndpointI));
i->resource = resource;
info = i;
fillEndpointInfo(info.get());
@@ -115,7 +115,7 @@ IceSSL::EndpointI::timeout(Int timeout) const
{
if(timeout == _timeout)
{
- return shared_from_this();
+ return ICE_SHARED_FROM_CONST_THIS(EndpointI);
}
else
{
@@ -128,7 +128,7 @@ IceSSL::EndpointI::connectionId(const string& connectionId) const
{
if(connectionId == _connectionId)
{
- return shared_from_this();
+ return ICE_SHARED_FROM_CONST_THIS(EndpointI);
}
else
{
@@ -147,7 +147,7 @@ IceSSL::EndpointI::compress(bool compress) const
{
if(compress == _compress)
{
- return shared_from_this();
+ return ICE_SHARED_FROM_CONST_THIS(EndpointI);
}
else
{
@@ -176,7 +176,7 @@ IceSSL::EndpointI::transceiver() const
IceInternal::AcceptorPtr
IceSSL::EndpointI::acceptor(const string&) const
{
- return new AcceptorI(ICE_DYNAMIC_CAST(EndpointI, shared_from_this()), _instance, _host, _port);
+ return new AcceptorI(ICE_DYNAMIC_CAST(EndpointI, ICE_SHARED_FROM_CONST_THIS(EndpointI)), _instance, _host, _port);
}
EndpointIPtr
diff --git a/cpp/test/Ice/acm/AllTests.cpp b/cpp/test/Ice/acm/AllTests.cpp
index 8c7e2f6a268..52c4922d98b 100644
--- a/cpp/test/Ice/acm/AllTests.cpp
+++ b/cpp/test/Ice/acm/AllTests.cpp
@@ -24,9 +24,12 @@ toString(int value)
return os.str();
}
-class LoggerI : public Ice::EnableSharedFromThis<LoggerI>,
- public Ice::Logger,
+class LoggerI : public Ice::Logger,
private IceUtil::Mutex
+#ifdef ICE_CPP11_MAPPING
+ , public std::enable_shared_from_this<LoggerI>
+#endif
+
{
public:
diff --git a/cpp/test/Ice/admin/TestI.cpp b/cpp/test/Ice/admin/TestI.cpp
index b7537b54a9d..00bd114404d 100644
--- a/cpp/test/Ice/admin/TestI.cpp
+++ b/cpp/test/Ice/admin/TestI.cpp
@@ -19,7 +19,10 @@ namespace
// A no-op Logger, used when testing the Logger Admin
//
-class NullLogger : public Ice::Logger, public Ice::EnableSharedFromThis<NullLogger>
+class NullLogger : public Ice::Logger
+#ifdef ICE_CPP11_MAPPING
+ , public std::enable_shared_from_this<NullLogger>
+#endif
{
public:
@@ -46,7 +49,7 @@ public:
virtual Ice::LoggerPtr cloneWithPrefix(const string&)
{
- return shared_from_this();
+ return ICE_SHARED_FROM_THIS;
}
};
diff --git a/cpp/test/Ice/background/EndpointI.cpp b/cpp/test/Ice/background/EndpointI.cpp
index 76748bea94a..2866395954c 100644
--- a/cpp/test/Ice/background/EndpointI.cpp
+++ b/cpp/test/Ice/background/EndpointI.cpp
@@ -68,7 +68,7 @@ EndpointI::timeout(int timeout) const
IceInternal::EndpointIPtr endpoint = _endpoint->timeout(timeout);
if(endpoint == _endpoint)
{
- return shared_from_this();
+ return ICE_SHARED_FROM_CONST_THIS(EndpointI);
}
else
{
@@ -82,7 +82,7 @@ EndpointI::connectionId(const string& connectionId) const
IceInternal::EndpointIPtr endpoint = _endpoint->connectionId(connectionId);
if(endpoint == _endpoint)
{
- return shared_from_this();
+ return ICE_SHARED_FROM_CONST_THIS(EndpointI);
}
else
{
@@ -102,7 +102,7 @@ EndpointI::compress(bool compress) const
IceInternal::EndpointIPtr endpoint = _endpoint->compress(compress);
if(endpoint == _endpoint)
{
- return shared_from_this();
+ return ICE_SHARED_FROM_CONST_THIS(EndpointI);
}
else
{
@@ -183,7 +183,7 @@ EndpointI::connectors_async(Ice::EndpointSelectionType selType, const IceInterna
IceInternal::AcceptorPtr
EndpointI::acceptor(const string& adapterName) const
{
- return new Acceptor(shared_from_this(), _endpoint->acceptor(adapterName));
+ return new Acceptor(ICE_SHARED_FROM_CONST_THIS(EndpointI), _endpoint->acceptor(adapterName));
}
/*IceInternal::EndpointIPtr
@@ -213,7 +213,7 @@ EndpointI::expand() const
vector<IceInternal::EndpointIPtr> e = _endpoint->expand();
for(vector<IceInternal::EndpointIPtr>::iterator p = e.begin(); p != e.end(); ++p)
{
- *p = (*p == _endpoint) ? shared_from_this() : ICE_MAKE_SHARED(EndpointI, *p);
+ *p = (*p == _endpoint) ? ICE_SHARED_FROM_CONST_THIS(EndpointI) : ICE_MAKE_SHARED(EndpointI, *p);
}
return e;
}
diff --git a/cpp/test/Ice/background/EndpointI.h b/cpp/test/Ice/background/EndpointI.h
index 2e8b823b7a4..cec84a2d0fd 100644
--- a/cpp/test/Ice/background/EndpointI.h
+++ b/cpp/test/Ice/background/EndpointI.h
@@ -18,7 +18,10 @@
class EndpointI;
ICE_DEFINE_PTR(EndpointIPtr, EndpointI);
-class EndpointI : public IceInternal::EndpointI, public Ice::EnableSharedFromThis<EndpointI>
+class EndpointI : public IceInternal::EndpointI
+#ifdef ICE_CPP11_MAPPING
+ , public std::enable_shared_from_this<EndpointI>
+#endif
{
public:
diff --git a/cpp/test/Ice/dispatcher/AllTests.cpp b/cpp/test/Ice/dispatcher/AllTests.cpp
index 7b79b132f9f..ae62ec16b69 100644
--- a/cpp/test/Ice/dispatcher/AllTests.cpp
+++ b/cpp/test/Ice/dispatcher/AllTests.cpp
@@ -18,7 +18,10 @@ using namespace std;
namespace
{
-class Callback : public ICE_SHARED
+class Callback
+#ifndef ICE_CPP11_MAPPING
+ : public IceUtil::Shared
+#endif
{
public:
diff --git a/cpp/test/Ice/slicing/objects/AllTests.cpp b/cpp/test/Ice/slicing/objects/AllTests.cpp
index cf6f1d45d9e..c24f1ca3013 100644
--- a/cpp/test/Ice/slicing/objects/AllTests.cpp
+++ b/cpp/test/Ice/slicing/objects/AllTests.cpp
@@ -52,7 +52,10 @@ private:
bool _called;
};
-class Callback : public CallbackBase, public Ice::EnableSharedFromThis<Callback>
+class Callback : public CallbackBase
+#ifndef ICE_CPP11_MAPPING
+ , public virtual IceUtil::Shared
+#endif
{
public: