20 #ifndef LIBMESH_REFERENCE_COUNTER_H 21 #define LIBMESH_REFERENCE_COUNTER_H 24 #include "libmesh/libmesh_config.h" 25 #include "libmesh/threads.h" 26 #include "libmesh/libmesh.h" 27 #include "libmesh/libmesh_exceptions.h" 98 #if defined(LIBMESH_ENABLE_REFERENCE_COUNTING) && defined(DEBUG) 118 typedef std::map<std::string, std::pair<
unsigned int,
181 #if defined(LIBMESH_ENABLE_REFERENCE_COUNTING) && defined(DEBUG) 188 std::pair<unsigned int, unsigned int> & p = _counts[
name];
194 stream->exceptions(stream->goodbit);
195 libMesh::err <<
"Encountered unrecoverable error while calling " 196 <<
"ReferenceCounter::increment_constructor_count() " 197 <<
"for a(n) " <<
name <<
" object." << std::endl;
205 #if defined(LIBMESH_ENABLE_REFERENCE_COUNTING) && defined(DEBUG) 212 std::pair<unsigned int, unsigned int> & p = _counts[
name];
218 stream->exceptions(stream->goodbit);
219 libMesh::err <<
"Encountered unrecoverable error while calling " 220 <<
"ReferenceCounter::increment_destructor_count() " 221 <<
"for a(n) " <<
name <<
" object." << std::endl;
231 #endif // LIBMESH_REFERENCE_COUNTER_H std::string name(const ElemQuality q)
This function returns a string containing some name for q.
static Threads::atomic< unsigned int > _n_objects
The number of objects.
static unsigned int n_objects()
Prints the number of outstanding (created, but not yet destroyed) objects.
void increment_constructor_count(const std::string &name) noexcept
Increments the construction counter.
static void print_info(std::ostream &out_stream=libMesh::out)
Prints the reference information, by default to libMesh::out.
The libMesh namespace provides an interface to certain functionality in the library.
~ReferenceCounter()
Destructor.
std::map< std::string, std::pair< unsigned int, unsigned int > > Counts
Data structure to log the information.
static std::string get_info()
Gets a string containing the reference information.
This is the base class for enabling reference counting.
static Threads::spin_mutex _mutex
Mutual exclusion object to enable thread-safe reference counting.
static bool _enable_print_counter
Flag to control whether reference count information is printed when print_info is called...
static void enable_print_counter_info()
Methods to enable/disable the reference counter output from print_info()
ReferenceCounter()
Constructors.
void increment_destructor_count(const std::string &name) noexcept
Increments the destruction counter.
static Counts _counts
Actually holds the data.
streamT * get()
Rather than implement every ostream/ios/ios_base function, we'll be lazy and make esoteric uses go th...
static void disable_print_counter_info()
void ErrorVector unsigned int
spin_mutex spin_mtx
A convenient spin mutex object which can be used for obtaining locks.