WeakRefServices Class Reference Data Structures

#include <weakrefservices.h>

静态公共成员函数

static MAXON_METHOD Bool   HasWeakReferences (const void *target)
static MAXON_METHOD Bool   AddWeakReference ( WeakRefBase &weakRef, const void *target)
static MAXON_METHOD void  RemoveWeakReference ( WeakRefBase &weakRef)
static MAXON_METHOD void  MoveWeakReference ( WeakRefBase &dst, WeakRefBase & src )
static MAXON_METHOD Bool   CopyWeakReference ( WeakRefBase &dst, const WeakRefBase & src )
static MAXON_WARN_UNUSED MAXON_METHOD Bool   ClearAllWeakReferences (const void *target)
static MAXON_METHOD Bool   TransferAllWeakReferences (const void *oldTarget, const void *newTarget)
static MAXON_METHOD Bool   AddObserver (const void *target, MemoryObserverCallback callback, void *callbackData)
static MAXON_METHOD Bool   AddMetadata (const void *target, const Id *uniqueId, void *metadata, MemoryMetadataDestructor destruct=nullptr)
static MAXON_METHOD Bool   EraseMetadata (const void *target, const Id *uniqueId)
static MAXON_METHOD MemoryMetadataProxy   GetMetadata (const void *target, const Id *uniqueId)
static MAXON_METHOD Result < Bool BrowseAllWeakReferences (const void *oldTarget, const ValueReceiver < WeakRefBase * > &receiver)

私有成员函数

  MAXON_INTERFACE_NONVIRTUAL ( WeakRefServices , MAXON_REFERENCE_NONE , "net.maxon.interface.weakrefservices")

成员函数文档编制

◆  MAXON_INTERFACE_NONVIRTUAL()

MAXON_INTERFACE_NONVIRTUAL ( WeakRefServices   ,
MAXON_REFERENCE_NONE   ,
"net.maxon.interface.weakrefservices"   
)
private

◆  HasWeakReferences()

static MAXON_METHOD Bool HasWeakReferences ( const void *  target )
static

Returns true if there currently are weak references to the target. This does not take other metadata into account, just the weak references.

参数
[in] target Pointer to strongly referenced target object, guaranteed to be valid and not nullptr.
返回
True if there are weak references to the target.

◆  AddWeakReference()

static MAXON_METHOD Bool AddWeakReference ( WeakRefBase weakRef ,
const void *  target  
)
static

Adds a weak reference to a strongly referenced object.

注意
The caller must hold a strong reference to the target object.
参数
[in] weakRef Weak reference.
[in] target Pointer to strongly referenced target object, guaranteed to be valid and not nullptr.
返回
True on success, false if reference could not be created (due to out of memory).

◆  RemoveWeakReference()

static MAXON_METHOD void RemoveWeakReference ( WeakRefBase weakRef )
static

Removes a weak reference.

参数
[in] weakRef Weak reference to be destructed.

◆  MoveWeakReference()

static MAXON_METHOD void MoveWeakReference ( WeakRefBase dst ,
WeakRefBase src  
)
static

Moves a weak reference.

参数
[in] dst Destination
[in] src Source

◆  CopyWeakReference()

static MAXON_METHOD Bool CopyWeakReference ( WeakRefBase dst ,
const WeakRefBase src  
)
static

Copies a weak reference.

参数
[in] dst Destination
[in] src Source
返回
True on success, false if copying failed (due to out of memory).

◆  ClearAllWeakReferences()

static MAXON_WARN_UNUSED MAXON_METHOD Bool ClearAllWeakReferences ( const void *  target )
static

Removes all weak references to a strongly referenced object (which is going to be destructed).

参数
[in] target Pointer to strongly referenced target object, guaranteed to be not nullptr.
返回
True if the target can be destructed, false if the ownership has been transferred and the target must not be destructed.

◆  TransferAllWeakReferences()

static MAXON_METHOD Bool TransferAllWeakReferences ( const void *  oldTarget ,
const void *  newTarget  
)
static

All weak references to oldTarget will be updated and point to newTarget. The caller holds a strong reference to the old target.

参数
[in] oldTarget Pointer to old target object (must be valid).
[in] newTarget Pointer to new target object (might be nullptr).
返回
True on success, false if copying failed (due to out of memory).

◆  AddObserver()

static MAXON_METHOD Bool AddObserver ( const void *  target ,
MemoryObserverCallback   callback ,
void *  callbackData  
)
static

Adds an observer which will be invoked before a strongly referenced object is destructed. The observer can claim (shared) ownership of the target by returning CLAIM_OWNERSHIP. In this case it should add a reference to it and destruct it at a later point in time. While the observer is called the internal metadata structure of the target is locked. You can request to be invoked after the target has been unlocked.

注意
You must not create or delete weak references or metadata which refer to the target inside the observer when the target is locked!
Since the observer is also performance critical it should be as short as possible and should only call code with known implications.
参数
[in] target Pointer to strongly referenced target object, guaranteed to be valid and not nullptr.
[in] callback Pointer to the callback.
[in] callbackData 数据 private to the callback.
返回
True on success, false if reference could not be created (due to out of memory).

◆  AddMetadata()

static MAXON_METHOD Bool AddMetadata ( const void *  target ,
const Id uniqueId ,
void *  metadata ,
MemoryMetadataDestructor   destruct = nullptr  
)
static

Adds metadata to a target object.

参数
[in] target Pointer to strongly referenced target object, guaranteed to be valid and not nullptr.
[in] uniqueId Unique pointer to an id (either an InternedId or a private static Id ).
[in] metadata Pointer to metadata (or the metadata itself).
[in] destruct Optional destructor for the metadata (to be called when the referenced object is destructed).
返回
True on success, false if metadata could not be added (due to out of memory).

◆  EraseMetadata()

static MAXON_METHOD Bool EraseMetadata ( const void *  target ,
const Id uniqueId  
)
static

Removes metadata from a target object.

参数
[in] target Pointer to strongly referenced target object, guaranteed to be valid and not nullptr.
[in] uniqueId Unique pointer to an id (either an InternedId or a private static Id ).
返回
True on success, false if no metadata existed.

◆  GetMetadata()

static MAXON_METHOD MemoryMetadataProxy GetMetadata ( const void *  target ,
const Id uniqueId  
)
static

Returns a proxy object which allows safe access to the metadata.

参数
[in] target Pointer to strongly referenced target object, guaranteed to be valid and not nullptr.
[in] uniqueId Unique pointer to an id (either an InternedId or a private static Id ).
返回
Proxy object for metadata.

◆  BrowseAllWeakReferences()

static MAXON_METHOD Result < Bool > BrowseAllWeakReferences ( const void *  oldTarget ,
const ValueReceiver < WeakRefBase * > &  receiver  
)
static