cesium-native
0.41.0
|
A reference-counted base class, meant to be used with IntrusivePointer. More...
#include <CesiumUtility/ReferenceCounted.h>
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. | |
A reference-counted base class, meant to be used with IntrusivePointer.
Consider using ReferenceCountedThreadSafe or ReferenceCountedNoThreadSafe instead of using this class directly.
T | The type that is deriving from this class. For example, you should declare your class as class MyClass : public ReferenceCounted<MyClass> { ... }; |
isThreadSafe | If 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.