From 06f084d4ba0ef4c5817c717afeaacb183554b020 Mon Sep 17 00:00:00 2001 From: Michele Caini Date: Fri, 19 May 2023 14:44:33 +0200 Subject: [PATCH] thread: getcpu --- src/uvw/thread.cpp | 4 ++++ src/uvw/thread.h | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/src/uvw/thread.cpp b/src/uvw/thread.cpp index a42cf6c3..c1cecf71 100644 --- a/src/uvw/thread.cpp +++ b/src/uvw/thread.cpp @@ -20,6 +20,10 @@ UVW_INLINE thread::type thread::self() noexcept { return uv_thread_self(); } +UVW_INLINE int thread::getcpu() noexcept { + return uv_thread_getcpu(); +} + UVW_INLINE bool thread::equal(const thread &tl, const thread &tr) noexcept { return !(0 == uv_thread_equal(tl.raw(), tr.raw())); } diff --git a/src/uvw/thread.h b/src/uvw/thread.h index a82e912c..6d65d7e1 100644 --- a/src/uvw/thread.h +++ b/src/uvw/thread.h @@ -60,6 +60,12 @@ public: */ static type self() noexcept; + /** + * @brief Gets the CPU number on which the calling thread is running. + * @return The CPU number on which the calling thread is running. + */ + static int getcpu() noexcept; + /** * @brief Compares thread by means of their identifiers. * @param tl A valid instance of a thread.