Skip to content

EntropyEngine::Core::EntropyObject

Ref-counted base with optional handle stamping and basic introspection. More…

#include <EntropyObject.h>

Inherited by EntropyCanvas::AssetOpState< EntropyCanvas::AssetUploadResult >, [EntropyCanvas::AssetOpState< void >](/api/EntropyCanvas/AssetOpState< void >/), EntropyEngine::Core::Graph::AcyclicNodeHandle< WorkGraphNode >, EntropyCanvas::AssetOpState< T >, [EntropyCanvas::AssetOpState< void >](/api/EntropyCanvas/AssetOpState< void >/), EntropyEngine::Core::Concurrency::WorkContractGroup, EntropyEngine::Core::Concurrency::WorkContractHandle, EntropyEngine::Core::EntropyApplication, EntropyEngine::Core::EntropyService, EntropyEngine::Core::Graph::AcyclicNodeHandle< T >, EntropyEngine::Core::IO::FileWatch, EntropyEngine::Core::IO::IFileSystemBackend, EntropyEngine::Networking::ConnectionHandle, EntropyEngine::Networking::ConnectionManager, EntropyEngine::Networking::LocalServer, EntropyEngine::Networking::NetworkConnection, EntropyEngine::Networking::NetworkSession, EntropyEngine::Networking::RemoteServer, EntropyEngine::Networking::SessionHandle, EntropyEngine::Networking::SessionManager

Name
structHandleCore
Optional handle identity stamped by an owner/registry.
Name
virtual~EntropyObject() =default
virtual const TypeSystem::TypeInfo *typeInfo() const
Optional richer type information; may be null.
booltryRetain() const
Attempts to retain only if the object is still alive.
virtual std::stringtoString() const
Human-readable short string (class@ptr by default).
voidretain() const
Increments the reference count.
voidrelease() const
Decrements the reference count and deletes when it reaches zero.
uint32_trefCount() const
Current reference count (approximate under contention).
EntropyObject &operator=(const EntropyObject & ) =delete
EntropyObject &operator=(EntropyObject && ) =delete
boolhasHandle() const
template <class OwnerT >
OwnerT *
handleOwnerAs() const
Returns the stamped owner pointer cast to the requested type.
const void *handleOwner() const
uint32_thandleIndex() const
uint64_thandleId() const
uint32_thandleGeneration() const
WeakControlBlock *getWeakControlBlock() const
Lazily retrieves or creates the weak control block.
virtual std::stringdescription() const
Long-form description; defaults to toString().
virtual std::stringdebugString() const
Debug-oriented string including refcount and handle when present.
virtual const char *className() const
Runtime class name for diagnostics and reflection.
virtual uint64_tclassHash() const
Stable type hash for cross-language identification.
EntropyObject() =default
EntropyObject(EntropyObject && ) =delete
EntropyObject(const EntropyObject & ) =delete
Name
void_setHandleIdentity(void * owner, uint32_t index, uint32_t generation)
void_clearHandleIdentity()
Name
std::atomic< WeakControlBlock * >_weakBlock
Lazily allocated control block for weak refs.
std::atomic< uint32_t >_refCount
Thread-safe retain/release counter.
struct EntropyEngine::Core::EntropyObject::HandleCore_handle
Name
structHandleAccess
class EntropyEngine::Core::EntropyObject;

Ref-counted base with optional handle stamping and basic introspection.

Designed for safe sharing across module/language boundaries. Reference count operations are thread-safe. When stamped with a handle identity, the object can participate in owner/index/generation validation without coupling to a specific handle type.

virtual ~EntropyObject() =default
inline virtual const TypeSystem::TypeInfo * typeInfo() const

Optional richer type information; may be null.

bool tryRetain() const

Attempts to retain only if the object is still alive.

Return: true on success (reference acquired), false if object already dead

Use when you need to safely grab a reference from a background thread without racing destruction. If the refcount has already reached zero, tryRetain() returns false and the object must not be used.

// Example: Try to use an object that might be concurrently released
if (obj->tryRetain()) {
doWork(obj);
obj->release();
} // else: object was already destroyed or being destroyed
virtual std::string toString() const

Human-readable short string (class@ptr by default).

Reimplemented by: EntropyEngine::Core::Concurrency::WorkContractGroup::toString, EntropyEngine::Core::Concurrency::WorkContractHandle::toString, EntropyEngine::Networking::ConnectionHandle::toString, EntropyEngine::Networking::ConnectionManager::toString, EntropyEngine::Networking::NamedPipeServer::toString, EntropyEngine::Networking::SessionHandle::toString, EntropyEngine::Networking::SessionManager::toString, EntropyEngine::Networking::UnixSocketServer::toString

void retain() const

Increments the reference count.

Note: Thread-safe; may be called from any thread.

void release() const

Decrements the reference count and deletes when it reaches zero.

Note: Thread-safe; may delete the object on the calling thread when count hits zero.

uint32_t refCount() const

Current reference count (approximate under contention).

EntropyObject & operator=(
const EntropyObject &
) =delete
EntropyObject & operator=(
EntropyObject &&
) =delete
inline bool hasHandle() const

Return: true if an owner has stamped this object with handle identity

template <class OwnerT >
inline OwnerT * handleOwnerAs() const

Returns the stamped owner pointer cast to the requested type.

Template Parameters:

  • OwnerT Expected owner class type (e.g., WorkContractGroup)

Return: Owner pointer cast to OwnerT*, or nullptr if not stamped

Note: Safe by construction: owners stamp the object with the true owner pointer

inline const void * handleOwner() const

Return: Owner pointer that stamped this object, or null if none

inline uint32_t handleIndex() const

Return: Index value stamped by the owner (undefined if !hasHandle())

inline uint64_t handleId() const

Return: 64-bit packed index:generation identifier (undefined if !hasHandle())

inline uint32_t handleGeneration() const

Return: Generation value stamped by the owner (undefined if !hasHandle())

WeakControlBlock * getWeakControlBlock() const

Lazily retrieves or creates the weak control block.

Return: Pointer to the control block (retained by the object)

virtual std::string description() const

Long-form description; defaults to toString().

Reimplemented by: EntropyEngine::Core::Concurrency::WorkContractGroup::description

virtual std::string debugString() const

Debug-oriented string including refcount and handle when present.

Reimplemented by: EntropyEngine::Core::Concurrency::WorkContractGroup::debugString

inline virtual const char * className() const

Runtime class name for diagnostics and reflection.

Reimplemented by: EntropyApplication::className, EntropyCanvas::AssetOpState::className, EntropyCanvas::AssetOpState::className, [EntropyCanvas::AssetOpState< void >::className](/api/EntropyCanvas/AssetOpState< void >/#function-classname), EntropyEngine::Core::Concurrency::WorkContractGroup::className, EntropyEngine::Core::Concurrency::WorkContractHandle::className, EntropyEngine::Core::EntropyApplication::className, EntropyEngine::Core::EntropyService::className, EntropyEngine::Core::Graph::AcyclicNodeHandle::className, EntropyEngine::Core::Graph::AcyclicNodeHandle::className, EntropyEngine::Core::IO::FileWatch::className, EntropyEngine::Core::IO::IFileSystemBackend::className, EntropyEngine::Core::IO::LocalFileSystemBackend::className, EntropyEngine::Networking::ConnectionHandle::className, EntropyEngine::Networking::ConnectionManager::className, EntropyEngine::Networking::NamedPipeServer::className, EntropyEngine::Networking::SessionHandle::className, EntropyEngine::Networking::SessionManager::className, EntropyEngine::Networking::UnixSocketServer::className

virtual uint64_t classHash() const

Stable type hash for cross-language identification.

Reimplemented by: EntropyEngine::Core::Concurrency::WorkContractGroup::classHash, EntropyEngine::Core::Concurrency::WorkContractHandle::classHash, EntropyEngine::Core::Graph::AcyclicNodeHandle::classHash, EntropyEngine::Core::Graph::AcyclicNodeHandle::classHash, EntropyEngine::Networking::ConnectionHandle::classHash, EntropyEngine::Networking::ConnectionManager::classHash, EntropyEngine::Networking::NamedPipeServer::classHash, EntropyEngine::Networking::SessionHandle::classHash, EntropyEngine::Networking::SessionManager::classHash, EntropyEngine::Networking::UnixSocketServer::classHash

EntropyObject() =default
EntropyObject(
EntropyObject &&
) =delete
EntropyObject(
const EntropyObject &
) =delete
inline void _setHandleIdentity(
void * owner,
uint32_t index,
uint32_t generation
)
inline void _clearHandleIdentity()
std::atomic< WeakControlBlock * > _weakBlock {nullptr};

Lazily allocated control block for weak refs.

std::atomic< uint32_t > _refCount {1};

Thread-safe retain/release counter.

struct EntropyEngine::Core::EntropyObject::HandleCore _handle;
friend struct HandleAccess(
HandleAccess
);

Updated on 2026-01-26 at 16:50:32 -0500