Skip to content

Commit

Permalink
Remove C++ GC, add Ice::SharedPtr for values (#1659)
Browse files Browse the repository at this point in the history
  • Loading branch information
bernardnormier authored Jan 11, 2024
1 parent ad22744 commit 5d85eeb
Show file tree
Hide file tree
Showing 76 changed files with 349 additions and 2,648 deletions.
39 changes: 39 additions & 0 deletions CHANGELOG-3.8.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,45 @@ This feature has been deprecated since Ice 3.7.
- An interface can no longer be used as a type This feature, known as "interface by value", has been deprecated since
Ice 3.7. You can still define proxies with the usual syntax, `Greeter*`, where `Greeter` represents an interface.

## C++ Changes

- The C++98 mapping is now called the Original mapping.

- The C++11 mapping is now called the New mapping.

- (Original mapping) The base class for mapped class instances is now Ice::Value, like in the new mapping. Previously,
Ice::Object was the base class for both mapped class instances and servants.

- (Original mapping) Ice::Value does not derive from IceUtil::Shared and the generated Ptr for mapped classed is now an
Ice::SharedPtr that behaves mostly like the previous IceUtil (and IceInternal) Handle by wrapping a std::shared_ptr.
The important differences are:
- the comparison operators of Ice::SharedPtr compare pointers like std::shared_ptr but unlike IceUtil::Handle.
- the pointed-to object no longer holds the reference count, and as result you must be careful and avoid creating
multiple SharedPtr managing the same object. For example:
```
MyClassPtr c1 = new MyClass(); // SharedPtr to class instance
MyClassPtr c2 = c1; // c1 and c2 point to the same instance
MyClassPtr c3 = c1.get(); // c3 points to the same instance. With Ice 3.7 and before, it's ok as it simply adds a
// a reference count to the shared instance. As of Ice 3.8, it's incorrect since c3 is a new
// independent SharedPtr with its own reference count.
```

- (Original mapping) Removed all support for garbage collection (GC) of class instances. If you create or receive a
graph of class instances with a cycle, you must break this cycle to avoid a leak.

- (New mapping) Ice::optional is now an alias for std::optional.

- (Original mapping) IceUtil::Optional is now an alias for std::optional. When upgrading from Ice 3.7 or earlier, you
need to replace calls to `get()` on IceUtil::Optional by calls to `value()`.

## Objective-C Changes

- The base class for class instances is now Ice::Value. Previously, Ice::Object was the base class for both mapped class
instances and servants.

- The slice compiler no longer generates an Objective-C protocol for Slice classes. It generates only an Objective-C
class (interface).

## Ice Service Changes

- The implementations of Glacier2, IceGrid, IceStorm and IcePatch2 were updated to use the new C++ mapping.
1 change: 0 additions & 1 deletion config/PropertyNames.xml
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,6 @@ generated from the section label.
<property name="ClassGraphDepthMax" />
<property name="ClientAccessPolicyProtocol" />
<property name="Compression.Level" />
<property name="CollectObjects"/>
<property name="Config" />
<property name="ConsoleListener" />
<property name="Default.CollocationOptimized" />
Expand Down
2 changes: 0 additions & 2 deletions cpp/config/Make.rules
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,6 @@ cpp11_projects = test/Common \
test/IceGrid/% \
test/IceBridge/simple

cpp11_excludes = test/Ice/gc

#
# If building on a Linux multilib platform, we restrict what we build for
# the 32-bits architecture. We basically, build the same set of components
Expand Down
1 change: 0 additions & 1 deletion cpp/include/Ice/Communicator.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
#include <Ice/Comparable.h>
#include <Ice/Proxy.h>
#include <Ice/Object.h>
#include <Ice/GCValue.h>
#include <Ice/Value.h>
#include <Ice/Incoming.h>
#include <Ice/IncomingAsync.h>
Expand Down
76 changes: 0 additions & 76 deletions cpp/include/Ice/GCValue.h

This file was deleted.

3 changes: 1 addition & 2 deletions cpp/include/Ice/Handle.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
#include <Ice/Config.h>

//
// "Handle" or "smart pointer" template for classes derived from
// IceInternal::GCShared, IceUtil::Shared, or IceUtil::SimpleShared.
// "Handle" or "smart pointer" template for classes derived from IceUtil::Shared, or IceUtil::SimpleShared.
//
// In contrast to IceUtil::Handle, IceInternal::Handle<T> can be used
// for a type T that has been declared but not defined. The only
Expand Down
18 changes: 2 additions & 16 deletions cpp/include/Ice/InputStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ patchHandle(void* addr, const ValuePtr& v)
IceInternal::Ex::throwUOE(T::ice_staticId(), v);
}
#else
IceInternal::Handle<T>* p = static_cast<IceInternal::Handle<T>*>(addr);
SharedPtr<T>* p = static_cast<SharedPtr<T>*>(addr);
_icePatchValuePtr(*p, v); // Generated _icePatchValuePtr function, necessary for forward declarations.
#endif
}
Expand Down Expand Up @@ -251,16 +251,6 @@ class ICE_API InputStream : public IceInternal::Buffer
void setCompactIdResolver(const CompactIdResolverPtr& r);
#endif

#ifndef ICE_CPP11_MAPPING
/**
* Indicates whether to mark instances of Slice classes as collectable. If the stream is
* initialized with a communicator, this setting defaults to the value of the
* Ice.CollectObjects property, otherwise the setting defaults to false.
* @param b True to mark instances as collectable, false otherwise.
*/
void setCollectObjects(bool b);
#endif

/**
* Indicates whether to slice instances of Slice classes to a known Slice type when a more
* derived type is unknown. An instance is "sliced" when no static information is available
Expand Down Expand Up @@ -1094,7 +1084,7 @@ class ICE_API InputStream : public IceInternal::Buffer
read(&patchHandle<T>, &v);
}
#else // C++98 mapping
template<typename T> void read(IceInternal::Handle<T>& v)
template<typename T> void read(Ice::SharedPtr<T>& v)
{
read(&patchHandle<T>, &v);
}
Expand Down Expand Up @@ -1476,10 +1466,6 @@ class ICE_API InputStream : public IceInternal::Buffer

Encaps _preAllocatedEncaps;

#ifndef ICE_CPP11_MAPPING
bool _collectObjects;
#endif

bool _traceSlicing;

size_t _classGraphDepthMax;
Expand Down
2 changes: 1 addition & 1 deletion cpp/include/Ice/MetricsAdminI.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ template<class MetricsType> class MetricsMapT : public MetricsMapI, private IceU
public:

typedef MetricsType T;
typedef ICE_INTERNAL_HANDLE<MetricsType> TPtr;
typedef ICE_SHARED_PTR<MetricsType> TPtr;

ICE_DEFINE_PTR(MetricsMapTPtr, MetricsMapT);

Expand Down
16 changes: 16 additions & 0 deletions cpp/include/Ice/MetricsFunctional.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,22 @@ template<typename R> struct ReferenceWrapper<const IceInternal::Handle<R>& >
return v.get();
}
};

template<typename R> struct ReferenceWrapper<Ice::SharedPtr<R> >
{
static R* get(const Ice::SharedPtr<R>& v)
{
return v.get();
}
};

template<typename R> struct ReferenceWrapper<const Ice::SharedPtr<R>& >
{
static R* get(const Ice::SharedPtr<R>& v)
{
return v.get();
}
};
#endif

template<typename R> struct ReferenceWrapper<R*>
Expand Down
2 changes: 1 addition & 1 deletion cpp/include/Ice/MetricsObserverI.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ template<typename T> class MetricsHelperT

virtual std::string operator()(const std::string&) const = 0;

virtual void initMetrics(const ICE_INTERNAL_HANDLE<T>&) const
virtual void initMetrics(const ICE_SHARED_PTR<T>&) const
{
// To be overridden in specialization to initialize state attributes
}
Expand Down
1 change: 0 additions & 1 deletion cpp/include/Ice/ObjectAdapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
#include <Ice/Comparable.h>
#include <Ice/Proxy.h>
#include <Ice/Object.h>
#include <Ice/GCValue.h>
#include <Ice/Value.h>
#include <Ice/Incoming.h>
#include <Ice/IncomingAsync.h>
Expand Down
3 changes: 0 additions & 3 deletions cpp/include/Ice/ObjectF.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ using ObjectPtr = ::std::shared_ptr<Object>;
#else
ICE_API Object* upCast(Object*);
typedef IceInternal::Handle<Object> ObjectPtr;
/// \cond INTERNAL
ICE_API void _icePatchValuePtr(ObjectPtr&, const ObjectPtr&);
/// \endcond
#endif

}
Expand Down
4 changes: 2 additions & 2 deletions cpp/include/Ice/OutputStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -810,9 +810,9 @@ class ICE_API OutputStream : public IceInternal::Buffer
* Writes a value instance to the stream.
* @param v The value to be written.
*/
template<typename T> void write(const IceInternal::Handle<T>& v)
template<typename T> void write(const Ice::SharedPtr<T>& v)
{
write(ValuePtr(upCast(v.get())));
write(ValuePtr(v));
}
#endif

Expand Down
1 change: 0 additions & 1 deletion cpp/include/Ice/Properties.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
#include <Ice/Comparable.h>
#include <Ice/Proxy.h>
#include <Ice/Object.h>
#include <Ice/GCValue.h>
#include <Ice/Value.h>
#include <Ice/Incoming.h>
#include <Ice/FactoryTableInit.h>
Expand Down
3 changes: 0 additions & 3 deletions cpp/include/Ice/PropertiesF.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,6 @@ ICE_API Object* upCast(PropertiesAdmin*);
typedef ::IceInternal::Handle< PropertiesAdmin> PropertiesAdminPtr;
typedef ::IceInternal::ProxyHandle< ::IceProxy::Ice::PropertiesAdmin> PropertiesAdminPrx;
typedef PropertiesAdminPrx PropertiesAdminPrxPtr;
/// \cond INTERNAL
ICE_API void _icePatchValuePtr(PropertiesAdminPtr&, const ObjectPtr&);
/// \endcond

}

Expand Down
Loading

0 comments on commit 5d85eeb

Please sign in to comment.