15 #ifndef LIBSTATISTICS_COLLECTOR__TOPIC_STATISTICS_COLLECTOR__RECEIVED_MESSAGE_PERIOD_HPP_
16 #define LIBSTATISTICS_COLLECTOR__TOPIC_STATISTICS_COLLECTOR__RECEIVED_MESSAGE_PERIOD_HPP_
29 namespace topic_statistics_collector
50 ResetTimeLastMessageReceived();
62 void OnMessageReceived(
const T & received_message,
const rcl_time_point_value_t now_nanoseconds)
63 override RCPPUTILS_TSA_REQUIRES(mutex_)
65 std::unique_lock<std::mutex> ulock{mutex_};
67 (void) received_message;
70 time_last_message_received_ = now_nanoseconds;
72 const std::chrono::nanoseconds nanos{now_nanoseconds - time_last_message_received_};
73 const auto period = std::chrono::duration_cast<std::chrono::milliseconds>(nanos);
74 time_last_message_received_ = now_nanoseconds;
106 ResetTimeLastMessageReceived();
119 void ResetTimeLastMessageReceived()
127 rcl_time_point_value_t time_last_message_received_ RCPPUTILS_TSA_GUARDED_BY(mutex_) =
129 mutable std::mutex mutex_;
135 #endif // LIBSTATISTICS_COLLECTOR__TOPIC_STATISTICS_COLLECTOR__RECEIVED_MESSAGE_PERIOD_HPP_