cesium-native  0.41.0
CesiumUtility::ReferenceCounted< T, isThreadSafe > Class Template Reference

A reference-counted base class, meant to be used with IntrusivePointer. More...

#include <CesiumUtility/ReferenceCounted.h>

Inheritance diagram for CesiumUtility::ReferenceCounted< T, isThreadSafe >:
CesiumUtility::ThreadIdHolder< true > CesiumAsync::SharedAssetDepot< TAssetType, TAssetKey > CesiumGltfReader::GltfSharedAssetSystem CesiumRasterOverlays::RasterOverlay CesiumRasterOverlays::RasterOverlayTile CesiumRasterOverlays::RasterOverlayTileProvider Cesium3DTilesSelection::TilesetSharedAssetSystem CesiumRasterOverlays::BingMapsRasterOverlay CesiumRasterOverlays::DebugColorizeTilesRasterOverlay CesiumRasterOverlays::IonRasterOverlay CesiumRasterOverlays::RasterizedPolygonsOverlay CesiumRasterOverlays::TileMapServiceRasterOverlay CesiumRasterOverlays::WebMapServiceRasterOverlay CesiumRasterOverlays::WebMapTileServiceRasterOverlay CesiumRasterOverlays::QuadtreeRasterOverlayTileProvider

Public Member Functions

void addReference () const
 Adds a counted reference to this object. Use CesiumUtility::IntrusivePointer instead of calling this method directly.
 
void releaseReference () const
 Removes a counted reference from this object. When the last reference is removed, this method will delete this instance. Use CesiumUtility::IntrusivePointer instead of calling this method directly.
 
std::int32_t getReferenceCount () const noexcept
 Returns the current reference count of this instance.
 

Detailed Description

template<typename T, bool isThreadSafe = true>
class CesiumUtility::ReferenceCounted< T, isThreadSafe >

A reference-counted base class, meant to be used with IntrusivePointer.

Consider using ReferenceCountedThreadSafe or ReferenceCountedNoThreadSafe instead of using this class directly.

Template Parameters
TThe type that is deriving from this class. For example, you should declare your class as class MyClass : public ReferenceCounted<MyClass> { ... };
isThreadSafeIf true, the reference count will be thread-safe by using std::atomic, allowing references to safely be added and removed from any thread at any time. The object will be destroyed in the thread that releases the last reference. If false, it uses a simple integer for the reference count, which is not thread safe. In this case, references must be added and removed (including automatically via IntrusivePointer) from only one thread at a time. However, this mode has a bit less overhead for objects that are only ever accessed from a single thread.

Definition at line 48 of file ReferenceCounted.h.


The documentation for this class was generated from the following file: