WeakRefTargetBase Struct Reference

#include <weakref.h>

Public Member Functions

const void * Lock () const
 
void Unlock (const void *target) const
 
 operator Bool () const
 
const void * GetCurrent () const
 
void UnlockCurrent () const
 
void Swap (const void *oldTarget, const void *newTarget)
 

Protected Attributes

AtomicUInt _target
 

Member Function Documentation

◆ Lock()

const void* Lock ( ) const

Locks the WeakRefTarget.

Note
After locking you must unlock as soon as possible, especially calling any method with unknown behaviour can easily lead to a deadlock. THREADSAFE.
Returns
Pointer to the current target.

◆ Unlock()

void Unlock ( const void *  target) const

Unlocks the WeakRefTarget. THREADSAFE.

Parameters
[in]targetPointer to the (new) target to be stored.

◆ operator Bool()

operator Bool ( ) const
explicit

Checks if there currently is a target.

Returns
True if there currently is a target, otherwise false.

◆ GetCurrent()

const void* GetCurrent ( ) const

Returns the current target pointer. Use Lock() and Unlock() to get a thread-safe pointer.

◆ UnlockCurrent()

void UnlockCurrent ( ) const

Unlocks the current target.

◆ Swap()

void Swap ( const void *  oldTarget,
const void *  newTarget 
)

Swaps old and new target.

Note
Use only if oldTarget is guaranteed to be valid, otherwise this will result in a freeze.
Parameters
[in]oldTargetPointer to the old target.
[in]newTargetPointer to the new target to be stored.

Member Data Documentation

◆ _target

AtomicUInt _target
mutableprotected