7 #ifndef LIBCARLA_ENABLE_LIFETIME_PROFILER 8 # define LIBCARLA_ENABLE_LIFETIME_PROFILER 9 #endif // LIBCARLA_ENABLE_LIFETIME_PROFILER 16 #include <unordered_map> 21 template <
typename ... Args>
22 static inline void log(Args && ... args) {
30 std::lock_guard<std::mutex> lock(
_mutex);
32 log(
"WARNING! the following objects were not destructed.");
34 log(item.second,
"still alive.");
40 void Register(
void *
object, std::string display_name) {
41 #if LIBCARLA_LOG_LEVEL <= LIBCARLA_LOG_LEVEL_DEBUG 42 log(
'+', display_name);
44 std::lock_guard<std::mutex> lock(
_mutex);
45 _objects.emplace(
object, std::move(display_name));
49 std::lock_guard<std::mutex> lock(
_mutex);
52 #if LIBCARLA_LOG_LEVEL <= LIBCARLA_LOG_LEVEL_DEBUG 62 std::unordered_map<void *, std::string>
_objects;
68 PROFILER.
Register(
this, std::move(display_name));
71 LifetimeProfiled::~LifetimeProfiled() {
LifetimeProfiled()=default
static void log(Args &&... args)
void Register(void *object, std::string display_name)
This file contains definitions of common data structures used in traffic manager. ...
#define DEBUG_ASSERT(predicate)
static LIBCARLA_NOINLINE void write_to_stream(std::ostream &out, Arg &&arg, Args &&... args)
static LifetimeProfiler PROFILER
void Deregister(void *object)
std::unordered_map< void *, std::string > _objects