#include <threadsaferef.h>

Template for safe access to BaseRef from multiple threads. This comes at the cost of extra atomic operations and will cause high contention if used thoughtless.
| REFERENCE | Type of the reference that will be stored thread-safe. |
Public Member Functions | |
| ThreadSafeRef () | |
| ThreadSafeRef (const REFERENCE &strongReference) | |
| ThreadSafeRef (const ThreadSafeRef &src) | |
| ThreadSafeRef (ThreadSafeRef &&src) | |
| ~ThreadSafeRef () | |
| ThreadSafeRef & | operator= (const REFERENCE &strongReference) |
| Bool | TryCompareAndSwap (const REFERENCE &strongReference, const REFERENCE &compare) |
| ThreadSafeRef & | operator= (const ThreadSafeRef &src) |
| ThreadSafeRef & | operator= (std::nullptr_t) |
| ThreadSafeRef & | operator= (ThreadSafeRef &&src) |
| REFERENCE | Get () const |
| operator REFERENCE () const | |
Private Types | |
| using | DereferencedPtr = typename REFERENCE::ReferencedType * |
Additional Inherited Members | |
Protected Member Functions inherited from ThreadSafePtr< REFERENCE::ReferencedType * > | |
| MAXON_IMPLICIT | ThreadSafePtr (REFERENCE::ReferencedType * src=nullptr) |
| ~ThreadSafePtr () | |
| REFERENCE::ReferencedType * | AcquirePtr () const |
| void | ReleasePtr (REFERENCE::ReferencedType * ptr) const |
| REFERENCE::ReferencedType * | ChangePtr (REFERENCE::ReferencedType * ptr) const |
| Bool | TryCompareAndSwapPtr (REFERENCE::ReferencedType * ptr, REFERENCE::ReferencedType * compare) const |
| REFERENCE::ReferencedType * | AttemptAcquirePtr () const |
Protected Attributes inherited from ThreadSafePtr< REFERENCE::ReferencedType * > | |
| AtomicUInt | _ptr |
|
private |
| ThreadSafeRef | ( | ) |
|
explicit |
| [in] | strongReference | BaseRef with strong reference to an object. |
| ThreadSafeRef | ( | const ThreadSafeRef< REFERENCE > & | src | ) |
Copy constructs a thread safe pointer. THREADSAFE.
| [in] | src | Source thread safe pointer. |
| ThreadSafeRef | ( | ThreadSafeRef< REFERENCE > && | src | ) |
Moves a thread safe pointer. THREADSAFE.
| [in] | src | Source thread safe pointer. |
| ~ThreadSafeRef | ( | ) |
THREADSAFE.
| ThreadSafeRef& operator= | ( | const REFERENCE & | strongReference | ) |
Adds a strong reference. THREADSAFE.
| [in] | strongReference | BaseRef with strong reference to an object. |
| Bool TryCompareAndSwap | ( | const REFERENCE & | strongReference, |
| const REFERENCE & | compare | ||
| ) |
| ThreadSafeRef& operator= | ( | const ThreadSafeRef< REFERENCE > & | src | ) |
Copies a thread safe pointer.
| [in] | src | Source thread safe pointer. |
| ThreadSafeRef& operator= | ( | std::nullptr_t | ) |
Resets the thread safe pointer.
| ThreadSafeRef& operator= | ( | ThreadSafeRef< REFERENCE > && | src | ) |
Moves a thread safe pointer.
| [in] | src | Source thread safe pointer. |
| REFERENCE Get | ( | ) | const |