Atlassian uses cookies to improve your browsing experience, perform analytics and research, and conduct advertising. Accept all cookies to indicate that you agree to our use of cookies on your device. Atlassian cookies and tracking notice, (opens new window)

Enlighten API 3.10 Documentation
Results will update as you type.
  • class Geo GeoFileStream
  • class Geo GeoFixedBinarySearchMap
  • class Geo GeoFixedBinarySearchMapCompare
  • class Geo GeoFixedPoolAllocator
  • class Geo GeoFixedString
  • class Geo GeoFlattenAndPackResults
  • class Geo GeoFp16Texture
  • class Geo GeoFpControl
  • class Geo GeoFrameTime
  • class Geo GeoFreeDestructor
  • class Geo GeoGenericTexture
  • class Geo GeoGuid
  • class Geo GeoHalf
  • class Geo GeoHashConstHandle
  • class Geo GeoHashCString
  • class Geo GeoHashDefault
  • class Geo GeoHashHandle
  • class Geo GeoHashMap
  • class Geo GeoHashString
  • class Geo GeoImmutableArray
  • class Geo GeoInputEvent
  • class Geo GeoInstanceCount
  • class Geo GeoIntRange
  • class Geo GeoIntrusivePtr
  • class Geo GeoKeyValueArray
  • class Geo GeoLineSegment
  • class Geo GeoList
  • class Geo GeoMap
  • class Geo GeoMemoryDefault
  • class Geo GeoMemoryPool
  • class Geo GeoMemoryStream
  • class Geo GeoNonAABoundingBox
  • class Geo GeoNoopDestructor
  • class Geo GeoPair
  • class Geo GeoParametrisedPlane3
  • class Geo GeoPriorityQueue
  • class Geo GeoProgress
  • class Geo GeoQueue
  • class Geo GeoQueueEnumInterface
  • class Geo GeoRefArrayPtr
  • class Geo GeoRefCount
  • class Geo GeoRefPtr
  • class Geo GeoRefReleasePtr
  • class Geo GeoReleaseDestructor
  • class Geo GeoRGBXTexture
  • class Geo GeoScopedCSection
  • class Geo GeoSingleton
  • class Geo GeoSpatialHash
  • class Geo GeoString
  • class Geo GeoTimer
  • class Geo GeoTokenList
  • class Geo GeoTokenStream
  • class Geo GeoTriangle
  • class Geo GeoTriple
  • class Geo GeoUniqueDelegatePtr
  • class Geo GeoUniquePtr
  • class Geo GeoUniqueReleasePtr
  • class Geo GeoV128Texture
  • class Geo GeoVariant
  • class Geo GeoVirtualPageAllocator
  • class Geo GeoZLibFileStream
  • class Geo GoodRNG
  • class Geo IdentDataCompare
  • class Geo IdentVertLinkBuilder
  • class Geo IdxLink
  • class Geo IffReader
  • class Geo IffTextWriter
  • class Geo IffWriter
  • class Geo IGeoEvent
  • class Geo IGeoInputStream
  • class Geo IGeoProgressProxy
  • class Geo IGeoRayTracingContext
  • class Geo IGeoReleasable
  • class Geo IGeoSerialisable
  • class Geo IGeoStream
  • class Geo IRtMesh
  • class Geo ITerminalCmdHandler
  • class Geo ITerminalDelegate
  • class Geo ITerminalInputHandler
  • class Geo ITerminalOutputHandler
  • class Geo Matrix
    Calendars

You‘re viewing this with anonymous access, so some content might be blocked.
/
class Geo GeoRefCount

    This is the documentation for Enlighten.

    class Geo GeoRefCount

    Nov 21, 2019

    class Geo::GeoRefCount

    Base class for reference counted resources.

    This class makes it possible to implement a 'poor man's garbage collection' in C++. Each class derived from this base class maintains a reference count, initially zero, incremented by the AddRef() method and decremented by the Release() method. If the reference count is zero after Release() has decremented it the object deletes itself by calling the destructor.

    Reference counting is designed to be used in conjunction with factory methods. For example one might define the class Foo which can be reference counted:

    class Foo : public GeoRefCount
    {
    public:
        static Foo* CreateFoo()
        {
            Foo* myFoo = GEO_NEW(Foo);      // Ref count will be 0
            if (!myFoo)     return 0;
            if (!myFoo->Setup(...))
            {
                // failed!
                GEO_DELETE(Foo, myFoo);
                return 0;
            }
            // success!
            myFoo->AddRef();    // ref count -> 1
            return myFoo;
        }
    protected:
        Foo()
        {
            // The constructor is protected so that Foo has to 
            // be allocated via the factory method. 
        }
    };
    
    To create a new instance of Foo, non-friends are forced to use the CreateFoo() factory method which leaves the reference count as one. Once the instance is finished with the Release() method is called. For example:
    ...
    Foo*    my_foo = Foo::CreateFoo();
    SomeExcitingFunction(my_foo);
    my_foo->Release();
    ...
    
    Suppose the SomeExcitingFunction() function wishes to keep the pointer to my_foo around for future use. In this case it should AddRef() it for as long as it wishes until it wants to Release() it.

    The rule of thumb for reference counting is if you AddRef() or Create...() it, you must at some point Release() it.

    GeoRefCount also allows the same class to be used in a non-ref-counted scenario. In this case you allow NEW and DELETE as usual, but once AddRef is called you must use Release. For instance, DirectGeoMeshLoader uses this strategy to return GeoMeshes which are "owned" by the caller, rather than just "existing" somewhere.

    Variables

    Name Description
    s32 m_RefCount

    The reference count, once it reaches zero the object deletes itself.

    Functions

    Name Description
    ~GeoRefCount()

    Virtual destructor required to make sure that the concrete class destructor gets called.

    AddRef()

    Increments the reference count and return new value.

    GeoRefCount()

    Default constructor. The reference count is initially zero.

    Release()

    Decrements the reference count, deleting the object if it reaches zero.


    virtual Geo::GeoRefCount::~GeoRefCount


    public: virtual ~GeoRefCount()


    Virtual destructor required to make sure that the concrete class destructor gets called.


    s32 Geo::GeoRefCount::AddRef


    public: s32 AddRef()


    Increments the reference count and return new value.

    Returns

    New value of reference count.


    Geo::GeoRefCount::GeoRefCount


    public: GeoRefCount()


    Default constructor. The reference count is initially zero.


    s32 Geo::GeoRefCount::Release


    public: s32 Release()


    Decrements the reference count, deleting the object if it reaches zero.

    Returns

    Returns reference count after decrement. 0 if deleted.

    , multiple selections available,
    {"serverDuration": 10, "requestCorrelationId": "d450e3d832a7475d83024587e594935b"}