11 , m_last_state_change_time(
now())
22 TLOG() <<
"LivetimeCounter stopping. Counts: " << report;
29 auto current_time=
now();
39 std::lock_guard<std::mutex> l(
m_mutex);
45std::map<LivetimeCounter::State, LivetimeCounter::state_time_t>
48 std::lock_guard<std::mutex> l(
m_mutex);
56 std::lock_guard<std::mutex> l(
m_mutex);
64 using namespace std::chrono;
65 return duration_cast<milliseconds>(steady_clock::now().time_since_epoch()).count();
71 std::lock_guard<std::mutex> l(
m_mutex);
73 std::ostringstream oss;
uint64_t state_time_t
A type to store a time duration in milliseconds.
std::map< State, state_time_t > m_state_times
state_time_t m_last_state_change_time
LivetimeCounter(State state)
Construct a LivetimeCounter in the given state.
std::string get_state_name(State state) const
std::string get_report_string()
Get a nicely-formatted string of the time spent in each state.
std::map< State, state_time_t > get_time_map()
Get a map of accumulated time in milliseconds in each state.
void set_state(State state)
Set the current state to state.
state_time_t get_time(State state)
Get the accumulated time in milliseconds spent in a particular state.
#define TLOG_DEBUG(lvl,...)