Thrill
0.1
|
Provides reference counting abilities for use with CountingPtr.
Use as superclass of the actual object, this adds a reference_count_ value. Then either use CountingPtr as pointer to manage references and deletion, or just do normal new and delete.
Definition at line 337 of file counting_ptr.hpp.
#include <counting_ptr.hpp>
Public Member Functions | |
ReferenceCounter () noexcept | |
new objects have zero reference count More... | |
ReferenceCounter (const ReferenceCounter &) noexcept | |
coping still creates a new object with zero reference count More... | |
~ReferenceCounter () | |
bool | dec_reference () const noexcept |
Call whenever resetting (i.e. More... | |
void | inc_reference () const noexcept |
Call whenever setting a pointer to the object. More... | |
ReferenceCounter & | operator= (const ReferenceCounter &) noexcept |
assignment operator, leaves pointers unchanged More... | |
size_t | reference_count () const noexcept |
Return the number of references to this object (for debugging) More... | |
bool | unique () const noexcept |
Test if the ReferenceCounter is referenced by only one CountingPtr. More... | |
Private Attributes | |
std::atomic< size_t > | reference_count_ |
|
inlinenoexcept |
new objects have zero reference count
Definition at line 346 of file counting_ptr.hpp.
|
inlinenoexcept |
coping still creates a new object with zero reference count
Definition at line 350 of file counting_ptr.hpp.
|
inline |
Definition at line 359 of file counting_ptr.hpp.
|
inlinenoexcept |
Call whenever resetting (i.e.
overwriting) a pointer to the object. IMPORTANT: In case of self-assignment, call AFTER inc_reference().
Definition at line 374 of file counting_ptr.hpp.
Referenced by file::delete_request_ref().
|
inlinenoexcept |
Call whenever setting a pointer to the object.
Definition at line 364 of file counting_ptr.hpp.
Referenced by file::add_request_ref().
|
inlinenoexcept |
assignment operator, leaves pointers unchanged
Definition at line 354 of file counting_ptr.hpp.
Referenced by DynBlockSourceAdapter< BlockSource >::DynBlockSourceAdapter().
|
inlinenoexcept |
Return the number of references to this object (for debugging)
Definition at line 384 of file counting_ptr.hpp.
Referenced by request::check_nref(), request::check_nref_failed(), file::get_request_nref(), ByteBlock::Deleter::operator()(), thrill::data::operator<<(), request::request(), File::~File(), request::~request(), and request_with_state::~request_with_state().
|
inlinenoexcept |
Test if the ReferenceCounter is referenced by only one CountingPtr.
Definition at line 380 of file counting_ptr.hpp.
|
mutableprivate |
the reference count is kept mutable for CountingPtr<const Type> to change the reference count.
Definition at line 342 of file counting_ptr.hpp.