Package icyllis.arc3d.core

# Annotation Interface SharedPtr

@Documented @Retention(CLASS) @Target({METHOD,PARAMETER,FIELD,LOCAL_VARIABLE,TYPE_USE}) public @interface SharedPtr
Denotes something like C++ std::shared_ptr. Differently, "ref" and "unref" are explicitly called in each SP "ctor" and "dtor" to ensure engine work correctly (because GC is not immediate, we don't rely on the lifecycle of Java objects). Some classes may have other methods in addition to the "unref" method (e.g. recycle), depending on how they (e.g. special SPs) are used.

When denote a method or parameter, the caller has referenced the object, then transfer ownership. When denote a field, the owner object has to unref it along with object itself. When there is no annotation, it is seen as raw ptr.

Denoted classes sometimes implement `AutoCloseable`, which is equivalent to "unref". Some classes may not need to be shared, or they may only be shared internally and have a unique owner object, or there are no underlying resources, or there is no need for immediacy. They may implement `AutoCloseable`, which is equivalent to "free" (or similar methods), you just need to manage their finalizing.

See Also:
  - `RefCounted`