This safely stores the primary, owned pointer to a CopyOnWriteObject. More...
#include "copyOnWritePointer.h"
Public Member Functions | |
CopyOnWritePointer (CopyOnWriteObject *object=nullptr) | |
CopyOnWritePointer (const CopyOnWritePointer ©) | |
CopyOnWritePointer (CopyOnWritePointer &&from) noexcept | |
CopyOnWritePointer (PointerTo< CopyOnWriteObject > &&from) noexcept | |
void | clear () |
Sets the pointer to NULL. More... | |
const CopyOnWriteObject * | get_read_pointer (Thread *current_thread) const |
Returns a pointer locked for read. More... | |
CopyOnWriteObject * | get_unsafe_pointer () |
Returns an unlocked pointer that you can write to. More... | |
CopyOnWriteObject * | get_write_pointer () |
Returns a pointer locked for write. More... | |
bool | is_null () const |
Returns true if the CopyOnWritePointer contains a NULL pointer, false otherwise. More... | |
bool | operator != (const CopyOnWritePointer &other) const |
bool | operator< (const CopyOnWritePointer &other) const |
void | operator= (const CopyOnWritePointer ©) |
void | operator= (CopyOnWritePointer &&from) noexcept |
void | operator= (PointerTo< CopyOnWriteObject > &&from) noexcept |
void | operator= (CopyOnWriteObject *object) |
bool | operator== (const CopyOnWritePointer &other) const |
bool | test_ref_count_integrity () const |
Does some easy checks to make sure that the reference count isn't completely bogus. More... | |
bool | test_ref_count_nonzero () const |
Does some easy checks to make sure that the reference count isn't zero, or completely bogus. More... | |
This safely stores the primary, owned pointer to a CopyOnWriteObject.
At any time, you may call get_read_pointer() or get_write_pointer() to get a read-only or modifiable pointer to the object stored.
There may be multiple copies of a CopyOnWritePointer which all refer to the same shared object. They will negotiate with each other properly.
Definition at line 31 of file copyOnWritePointer.h.
|
inline |
Sets the pointer to NULL.
Definition at line 220 of file copyOnWritePointer.I.
References cache_unref_delete().
|
inline |
Returns a pointer locked for read.
Until this pointer dereferences, calls to get_write_pointer() will force a copy.
This flavor of the method is written for the non-threaded case.
Definition at line 167 of file copyOnWritePointer.I.
Referenced by CopyOnWritePointerTo< T >::get_read_pointer().
|
inline |
Returns an unlocked pointer that you can write to.
This should only be used in very narrow circumstances in which you know that no other thread may be accessing the pointer at the same time.
Definition at line 203 of file copyOnWritePointer.I.
Referenced by CopyOnWritePointerTo< T >::get_unsafe_pointer().
|
inline |
Returns a pointer locked for write.
If another thread or threads already hold the pointer locked for read, then this will force a copy.
Until this pointer dereferences, calls to get_read_pointer() or get_write_pointer() will block.
This flavor of the method is written for the non-threaded case.
Definition at line 183 of file copyOnWritePointer.I.
References CachedTypedWritableReferenceCount::get_cache_ref_count.
Referenced by CopyOnWritePointerTo< T >::get_write_pointer().
|
inline |
Returns true if the CopyOnWritePointer contains a NULL pointer, false otherwise.
Definition at line 212 of file copyOnWritePointer.I.
|
inline |
Does some easy checks to make sure that the reference count isn't completely bogus.
Returns true if ok, false otherwise.
Definition at line 232 of file copyOnWritePointer.I.
|
inline |
Does some easy checks to make sure that the reference count isn't zero, or completely bogus.
Returns true if ok, false otherwise.
Definition at line 242 of file copyOnWritePointer.I.