#include <audio/utility/safeptr.h>
Public Member Functions | |
SafeOwner ()=default | |
SafeOwner (DeletionQueue &deletionQueue, T *ptr) | |
~SafeOwner () | |
SafeOwner (const std::nullptr_t) | |
SafeOwner & | operator= (const std::nullptr_t) |
SafeOwner (const SafeOwner &other)=delete | |
SafeOwner & | operator= (const SafeOwner &other)=delete |
SafeOwner (SafeOwner< T > &&other) | |
SafeOwner< T > & | operator= (SafeOwner< T > &&other) |
template<typename OTHER > | |
SafeOwner (SafeOwner< OTHER > &&other) | |
template<typename OTHER > | |
SafeOwner< T > & | operator= (SafeOwner< OTHER > &&other) |
const T & | operator* () const |
T & | operator* () |
T * | operator-> () const |
T * | operator-> () |
template<typename OTHER > | |
bool | operator== (const OTHER *ptr) const |
template<typename OTHER > | |
bool | operator!= (const OTHER *ptr) const |
bool | operator== (const std::nullptr_t) const |
bool | operator!= (const std::nullptr_t) const |
SafePtr< T > | get () |
SafePtr< T > | get () const |
T * | getRaw () |
T * | getRaw () const |
Protected Member Functions | |
void * | getData () override |
void | setData (void *data) override |
DeletionQueue * | getDeletionQueue () override |
void | setDeletionQueue (DeletionQueue *queue) override |
SafeOwner is a special case smart pointer to an object that is used in multiple threads. It serves the purpose of making sure that the object is destructed in a thread safe manner when the SafeOwner goes out of scope. It works very much like unique_ptr in such that it takes ownership over the object it points to and takes responsibility for it's destruction. The difference to unique_ptr is that instead of letting the object destruct itself when the pointer goes out of scope, it throws the object in a DeletionQueue. Objects in the DeletionQueue are kept alive until the DeletionQueue is cleared at a moment when there is noone else using the object anymore. This is done to prevent the objects to be destroyed while they are possibly being used in another thread at the same time.
|
default |
SafeOwner | ( | DeletionQueue & | deletionQueue, |
T * | ptr | ||
) |
The constructor takes the DeletionQueue that the owner will use to dispose it's managed object and a pointer to the object it will manage.
~SafeOwner | ( | ) |
The destructor of the SafeOwner base class. Instead of letting the managed object destruct itself it is thrown into the DeletionQueue, from which it will be deleted on a safe moment.
SafeOwner | ( | const std::nullptr_t | ) |
SafePtr<T> get | ( | ) |
Returns a SafePtr to the owned object. The SafePtr (and all it's future copies) will be set to nullptr when the managed object will be destroyed by the DeletionQueue.
SafePtr<T> get | ( | ) | const |
Returns a const SafePtr to the owned object. The SafePtr (and all it's future copies) will be set to nullptr when the managed object will be destroyed by the DeletionQueue.
|
overrideprotected |
|
overrideprotected |
T* getRaw | ( | ) |
Returns a raw pointer to the owned object.
T* getRaw | ( | ) | const |
Returns a const raw pointer to the owned object.
bool operator!= | ( | const OTHER * | ptr | ) | const |
bool operator!= | ( | const std::nullptr_t | ) | const |
T& operator* | ( | ) |
const T& operator* | ( | ) | const |
T* operator-> | ( | ) |
T* operator-> | ( | ) | const |
SafeOwner& operator= | ( | const std::nullptr_t | ) |
bool operator== | ( | const OTHER * | ptr | ) | const |
bool operator== | ( | const std::nullptr_t | ) | const |
|
overrideprotected |
|
overrideprotected |