v1.4.4
This commit is contained in:
commit
9c94d113d3
10260 changed files with 1237388 additions and 0 deletions
54
attic/old_source/StarLiveCounter.hpp
Normal file
54
attic/old_source/StarLiveCounter.hpp
Normal file
|
@ -0,0 +1,54 @@
|
|||
#ifndef STAR_LIVE_COUNTER_HPP
|
||||
#define STAR_LIVE_COUNTER_HPP
|
||||
|
||||
#include "StarConfig.hpp"
|
||||
|
||||
#include <typeindex>
|
||||
|
||||
namespace Star {
|
||||
|
||||
typedef atomic<int64_t> LiveAtomicCounter;
|
||||
|
||||
void bindLiveCounter(std::type_index const& typeIndex, LiveAtomicCounter*& counter);
|
||||
void dumpLiveCounters();
|
||||
|
||||
// Use as class MyClass : LiveCounter<MyClass> { ... }
|
||||
template<typename T>
|
||||
class LiveCounter {
|
||||
public:
|
||||
#ifdef STAR_ENABLE_LIVECOUNTER
|
||||
LiveCounter() {
|
||||
bindLiveCounter(typeid(T), s_liveCounter);
|
||||
++(*s_liveCounter);
|
||||
}
|
||||
|
||||
LiveCounter(LiveCounter const&) {
|
||||
bindLiveCounter(typeid(T), s_liveCounter);
|
||||
++(*s_liveCounter);
|
||||
}
|
||||
|
||||
LiveCounter(LiveCounter&&) {
|
||||
bindLiveCounter(typeid(T), s_liveCounter);
|
||||
++(*s_liveCounter);
|
||||
}
|
||||
|
||||
void operator=(LiveCounter const&) {}
|
||||
|
||||
void operator=(LiveCounter&&) {}
|
||||
|
||||
~LiveCounter() {
|
||||
--(*s_liveCounter);
|
||||
}
|
||||
private:
|
||||
static LiveAtomicCounter* s_liveCounter;
|
||||
#endif
|
||||
};
|
||||
|
||||
#ifdef STAR_ENABLE_LIVECOUNTER
|
||||
template<typename T>
|
||||
LiveAtomicCounter* LiveCounter<T>::s_liveCounter = nullptr;
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue