From 138cbb94b245f424d963cb97e773da6081b53010 Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Wed, 20 Oct 2021 08:44:33 -0700 Subject: [PATCH] [wpiutil] uv::Async: Add direct call for no-parameter specialization (#3648) --- wpiutil/src/main/native/include/wpi/uv/Async.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/wpiutil/src/main/native/include/wpi/uv/Async.h b/wpiutil/src/main/native/include/wpi/uv/Async.h index 3598d09334..49f3dde4ed 100644 --- a/wpiutil/src/main/native/include/wpi/uv/Async.h +++ b/wpiutil/src/main/native/include/wpi/uv/Async.h @@ -151,7 +151,12 @@ class Async<> final : public HandleImpl, uv_async_t> { */ void Send() { if (auto loop = m_loop.lock()) { - Invoke(&uv_async_send, GetRaw()); + if (loop->GetThreadId() == std::this_thread::get_id()) { + // called from within the loop, just call the function directly + wakeup(); + } else { + Invoke(&uv_async_send, GetRaw()); + } } }