This class implements reference counting. 更多...
#include <reference_counted_object.h>
Public 成员函数 | |
~ReferenceCountedObject () | |
Destructor. 更多... | |
静态 Public 成员函数 | |
static std::string | get_info () |
Gets a string containing the reference information. 更多... | |
static void | print_info (std::ostream &out_stream=libMesh::out) |
Prints the reference information, by default to libMesh::out . 更多... | |
static unsigned int | n_objects () |
Prints the number of outstanding (created, but not yet destroyed) objects. 更多... | |
static void | enable_print_counter_info () |
Methods to enable/disable the reference counter output from print_info() 更多... | |
static void | disable_print_counter_info () |
Protected 类型 | |
typedef std::map< std::string, std::pair< unsigned int, unsigned int > > | Counts |
Data structure to log the information. 更多... | |
Protected 成员函数 | |
ReferenceCountedObject () | |
Constructor. 更多... | |
ReferenceCountedObject (const ReferenceCountedObject &other) | |
Also, increment the counter if the copy-constructor is called. 更多... | |
ReferenceCountedObject (ReferenceCountedObject &&other) noexcept | |
Move constructor, must be declared noexcept. 更多... | |
ReferenceCountedObject & | operator= (const ReferenceCountedObject &) |
Copy assignment operator does nothing - we're copying an already-allocated object over an already-allocated object, so the counts for this class shouldn't change. 更多... | |
void | increment_constructor_count (const std::string &name) noexcept |
Increments the construction counter. 更多... | |
void | increment_destructor_count (const std::string &name) noexcept |
Increments the destruction counter. 更多... | |
静态 Protected 属性 | |
static Counts | _counts |
Actually holds the data. 更多... | |
static Threads::atomic < unsigned int > | _n_objects |
The number of objects. 更多... | |
static Threads::spin_mutex | _mutex |
Mutual exclusion object to enable thread-safe reference counting. 更多... | |
static bool | _enable_print_counter = true |
Flag to control whether reference count information is printed when print_info is called. 更多... | |
This class implements reference counting.
Any class that is properly derived from this class will get reference counted, provided that the library is configured with –enable-reference-counting
and you are compiling with DEBUG
defined. For example, the following is sufficient to define the class Foo
as a reference counted class:
–disable-reference-counting
or DEBUG
is not defined then this class does nothing. All members are inlined and empty, so they should effectively disappear.在文件 reference_counted_object.h 第 65 行定义.
|
protectedinherited |
Data structure to log the information.
The log is identified by the class name.
在文件 reference_counter.h 第 119 行定义.
|
inlineprotected |
Constructor.
Protected so that you cannot instantiate a ReferenceCountedObject
, only derive from it.
在文件 reference_counted_object.h 第 74 行定义.
|
inlineprotected |
Also, increment the counter if the copy-constructor is called.
在文件 reference_counted_object.h 第 86 行定义.
|
inlineprotectednoexcept |
Move constructor, must be declared noexcept.
在文件 reference_counted_object.h 第 99 行定义.
|
inline |
Destructor.
在文件 reference_counted_object.h 第 127 行定义.
|
staticinherited |
在文件 reference_counter.C 第 100 行定义.
参考 libMesh::ReferenceCounter::_enable_print_counter.
|
staticinherited |
Methods to enable/disable the reference counter output from print_info()
在文件 reference_counter.C 第 94 行定义.
参考 libMesh::ReferenceCounter::_enable_print_counter.
|
staticinherited |
Gets a string containing the reference information.
在文件 reference_counter.C 第 47 行定义.
参考 libMesh::ReferenceCounter::_counts.
参考自 libMesh::ReferenceCounter::print_info().
|
inlineprotectednoexceptinherited |
Increments the construction counter.
Should be called in the constructor of any derived class that will be reference counted.
在文件 reference_counter.h 第 183 行定义.
参考 libMesh::err.
参考自 libMesh::ReferenceCountedObject< SparseMatrix< T > >::ReferenceCountedObject().
|
inlineprotectednoexceptinherited |
Increments the destruction counter.
Should be called in the destructor of any derived class that will be reference counted.
在文件 reference_counter.h 第 207 行定义.
参考 libMesh::err.
参考自 libMesh::ReferenceCountedObject< SparseMatrix< T > >::~ReferenceCountedObject().
|
inlinestaticinherited |
Prints the number of outstanding (created, but not yet destroyed) objects.
在文件 reference_counter.h 第 85 行定义.
参考 libMesh::ReferenceCounter::_n_objects.
参考自 libMesh::LibMeshInit::~LibMeshInit().
|
inlineprotected |
Copy assignment operator does nothing - we're copying an already-allocated object over an already-allocated object, so the counts for this class shouldn't change.
There are also no non-static members in this or the base class to copy, so there is nothing for us to actually do.
在文件 reference_counted_object.h 第 116 行定义.
|
staticinherited |
Prints the reference information, by default to libMesh::out
.
在文件 reference_counter.C 第 81 行定义.
参考 libMesh::ReferenceCounter::_enable_print_counter , 以及 libMesh::ReferenceCounter::get_info().
参考自 libMesh::LibMeshInit::~LibMeshInit().
|
staticprotectedinherited |
Actually holds the data.
在文件 reference_counter.h 第 124 行定义.
|
staticprotectedinherited |
Flag to control whether reference count information is printed when print_info is called.
在文件 reference_counter.h 第 143 行定义.
参考自 libMesh::ReferenceCounter::disable_print_counter_info(), libMesh::ReferenceCounter::enable_print_counter_info() , 以及 libMesh::ReferenceCounter::print_info().
|
staticprotectedinherited |
Mutual exclusion object to enable thread-safe reference counting.
在文件 reference_counter.h 第 137 行定义.
|
staticprotectedinherited |
The number of objects.
Print the reference count information when the number returns to 0.
在文件 reference_counter.h 第 132 行定义.
参考自 libMesh::ReferenceCounter::n_objects(), libMesh::ReferenceCounter::ReferenceCounter() , 以及 libMesh::ReferenceCounter::~ReferenceCounter().