util/thread_ctrl: Method for measuring cycles a thread has run for

Also add a getter for the native thread handle.
This commit is contained in:
VelocityRa 2018-05-24 22:22:07 +03:00 committed by kd-11
parent 5defa9c7b0
commit 8981227644
2 changed files with 43 additions and 0 deletions

View file

@ -138,6 +138,9 @@ class thread_ctrl final
// Fixed name
std::string m_name;
// CPU cycles thread has run for
u64 m_cycles{0};
// Start thread
static void start(const std::shared_ptr<thread_ctrl>&, task_stack);
@ -172,6 +175,15 @@ public:
return m_name;
}
// Get CPU cycles since last time this function was called. First call returns 0.
u64 get_cycles();
// Get platform-specific thread handle
std::uintptr_t get_native_handle() const
{
return m_thread.load();
}
// Get exception
std::exception_ptr get_exception() const;