From cf9574b4120dd9c888ff43845f5ebc465aaf8afd Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 15 Feb 2022 17:31:18 +0100 Subject: [PATCH] pstats: Add convenience method for ticking current thread only --- panda/src/pstatclient/pStatClient.cxx | 29 +++++++++++++++++++++++++++ panda/src/pstatclient/pStatClient.h | 4 ++++ 2 files changed, 33 insertions(+) diff --git a/panda/src/pstatclient/pStatClient.cxx b/panda/src/pstatclient/pStatClient.cxx index 2bec9b2c43..657badb048 100644 --- a/panda/src/pstatclient/pStatClient.cxx +++ b/panda/src/pstatclient/pStatClient.cxx @@ -373,6 +373,14 @@ main_tick() { get_global_pstats()->client_main_tick(); } +/** + * A convenience function to call new_frame() for the current thread. + */ +void PStatClient:: +thread_tick() { + get_global_pstats()->client_thread_tick(); +} + /** * A convenience function to call new_frame() on any threads with the * indicated sync_name @@ -410,6 +418,19 @@ client_main_tick() { } } +/** + * A convenience function to call new_frame() on the current thread. + */ +void PStatClient:: +client_thread_tick() { + ReMutexHolder holder(_lock); + + if (has_impl()) { + PStatThread thread = do_get_current_thread(); + _impl->new_frame(thread.get_index()); + } +} + /** * A convenience function to call new_frame() on all of the threads with the * indicated sync name. @@ -1285,6 +1306,10 @@ void PStatClient:: main_tick() { } +void PStatClient:: +thread_tick() { +} + void PStatClient:: thread_tick(const std::string &) { } @@ -1293,6 +1318,10 @@ void PStatClient:: client_main_tick() { } +void PStatClient:: +client_thread_tick() { +} + void PStatClient:: client_thread_tick(const std::string &sync_name) { } diff --git a/panda/src/pstatclient/pStatClient.h b/panda/src/pstatclient/pStatClient.h index 56bd0d2a1b..9b17f208f3 100644 --- a/panda/src/pstatclient/pStatClient.h +++ b/panda/src/pstatclient/pStatClient.h @@ -95,9 +95,11 @@ PUBLISHED: INLINE static void resume_after_pause(); static void main_tick(); + static void thread_tick(); static void thread_tick(const std::string &sync_name); void client_main_tick(); + void client_thread_tick(); void client_thread_tick(const std::string &sync_name); bool client_connect(std::string hostname, int port); void client_disconnect(); @@ -291,10 +293,12 @@ PUBLISHED: INLINE static void resume_after_pause() { } static void main_tick(); + static void thread_tick(); static void thread_tick(const std::string &); public: void client_main_tick(); + void client_thread_tick(); void client_thread_tick(const std::string &sync_name); bool client_connect(std::string hostname, int port); void client_disconnect();