Derive from RefCounted if you want to enable reference counting of this class.
More...
#include <refcnt.hh>
|
| | RefCounted () |
| | We initialize the reference count to zero and the first object to take ownership of it must increment it to one.
|
| |
| virtual | ~RefCounted () |
| | We make the destructor virtual because we're likely to have virtual functions on reference counted objects.
|
| |
| void | incref () const |
| | Increment the reference count.
|
| |
| void | decref () const |
| | Decrement the reference count and destroy the object if all references are gone.
|
| |
Derive from RefCounted if you want to enable reference counting of this class.
If you want to use automatic reference counting, you should use RefCountingPtr<T> instead of regular pointers.
Definition at line 60 of file refcnt.hh.
◆ RefCounted() [1/2]
| gem5::RefCounted::RefCounted |
( |
const RefCounted & | | ) |
|
|
private |
◆ RefCounted() [2/2]
| gem5::RefCounted::RefCounted |
( |
| ) |
|
|
inline |
We initialize the reference count to zero and the first object to take ownership of it must increment it to one.
- Attention
- A memory leak will occur if you never assign a newly constructed object to a reference counting pointer.
Definition at line 84 of file refcnt.hh.
References count.
◆ ~RefCounted()
| virtual gem5::RefCounted::~RefCounted |
( |
| ) |
|
|
inlinevirtual |
We make the destructor virtual because we're likely to have virtual functions on reference counted objects.
- Todo
- Even if this were true, does it matter? Shouldn't the derived class indicate this? This only matters if we would ever choose to delete a "RefCounted *" which I doubt we'd ever do. We don't ever delete a "void *".
Definition at line 95 of file refcnt.hh.
◆ decref()
| void gem5::RefCounted::decref |
( |
| ) |
const |
|
inline |
Decrement the reference count and destroy the object if all references are gone.
Definition at line 103 of file refcnt.hh.
References count.
◆ incref()
| void gem5::RefCounted::incref |
( |
| ) |
const |
|
inline |
Increment the reference count.
Definition at line 98 of file refcnt.hh.
References count.
◆ operator=()
◆ count
| int gem5::RefCounted::count |
|
mutableprivate |
The documentation for this class was generated from the following file: