MemoryMetadataProxy Struct Reference

#include <weakrefservices.h>

Detailed Description

Proxy object to access memory metadata. While the proxy object exists the metadata for the target is locked and cannot be accessed or modified by other threads (in fact all metadata for the target including weak references is locked). Therefore best practice is to destroy the proxy object as soon as possible.

Public Member Functions

 MAXON_DISALLOW_COPY_AND_ASSIGN (MemoryMetadataProxy)
 
 MemoryMetadataProxy ()=default
 
 MemoryMetadataProxy (MemoryMetadataProxy &&)=default
 
 MemoryMetadataProxy (WeakRefTargetBase *weakRefTarget, void *metadata)
 
 MAXON_OPERATOR_MOVE_ASSIGNMENT (MemoryMetadataProxy)
 
 ~MemoryMetadataProxy ()
 
 operator Bool () const
 
Result< void * > Get () const
 

Private Attributes

WeakRefTargetBase_weakRefTarget
 
void * _metadata
 

Constructor & Destructor Documentation

◆ MemoryMetadataProxy() [1/3]

MemoryMetadataProxy ( )
default

◆ MemoryMetadataProxy() [2/3]

◆ MemoryMetadataProxy() [3/3]

MemoryMetadataProxy ( WeakRefTargetBase weakRefTarget,
void *  metadata 
)
explicit

◆ ~MemoryMetadataProxy()

Destructs the proxy object and unlocks access to the metadata.

Member Function Documentation

◆ MAXON_DISALLOW_COPY_AND_ASSIGN()

MAXON_DISALLOW_COPY_AND_ASSIGN ( MemoryMetadataProxy  )

◆ MAXON_OPERATOR_MOVE_ASSIGNMENT()

MAXON_OPERATOR_MOVE_ASSIGNMENT ( MemoryMetadataProxy  )

◆ operator Bool()

operator Bool ( ) const
explicit

◆ Get()

Result<void*> Get ( void  ) const

Returns the memory metadata (or an error if there wasn't any).

Returns
Memory metadata on success.

Member Data Documentation

◆ _weakRefTarget

WeakRefTargetBase* _weakRefTarget
private

◆ _metadata

void* _metadata
private