7#ifndef LIBCARLA_ENABLE_LIFETIME_PROFILER
8# define 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;
71 LifetimeProfiled::~LifetimeProfiled() {
#define DEBUG_ASSERT(predicate)
LifetimeProfiled()=default
std::unordered_map< void *, std::string > _objects
void Deregister(void *object)
void Register(void *object, std::string display_name)
static LIBCARLA_NOINLINE void write_to_stream(std::ostream &out, Arg &&arg, Args &&... args)
static void log(Args &&... args)
static LifetimeProfiler PROFILER
This file contains definitions of common data structures used in traffic manager.