From 75d9ba733f4a041e4320098b52903f69747df02b Mon Sep 17 00:00:00 2001 From: Alexander Sklar Date: Thu, 4 Mar 2021 12:41:24 -0800 Subject: [PATCH] Detach thread in executeAsynchronously (RuntimeExecutor.h) (#31090) Summary: std::thread's constructor is nodiscard. This breaks in MSVC 16.9 when nodiscard starts to be enforced. Either we should hold on to the created object or detach the temporary which is what I think this function intends to do anyway. Fixes https://github.com/facebook/react-native/issues/31088 Fixes an invalid usage of std::thread's constructor ## Changelog [General] [Fixed] - fixes usage of std::thread in runtime executor Pull Request resolved: https://github.com/facebook/react-native/pull/31090 Reviewed By: sammy-SC Differential Revision: D26783963 Pulled By: appden fbshipit-source-id: fed4d072792aafa058dd742e8fce30a207f991c1 --- ReactCommon/runtimeexecutor/ReactCommon/RuntimeExecutor.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ReactCommon/runtimeexecutor/ReactCommon/RuntimeExecutor.h b/ReactCommon/runtimeexecutor/ReactCommon/RuntimeExecutor.h index 90139a6a99cfea..ab73c6c8e23d17 100644 --- a/ReactCommon/runtimeexecutor/ReactCommon/RuntimeExecutor.h +++ b/ReactCommon/runtimeexecutor/ReactCommon/RuntimeExecutor.h @@ -39,9 +39,9 @@ using RuntimeExecutor = inline static void executeAsynchronously( RuntimeExecutor const &runtimeExecutor, std::function &&callback) noexcept { - std::thread{[callback = std::move(callback), runtimeExecutor]() mutable { + std::thread([callback = std::move(callback), runtimeExecutor]() mutable { runtimeExecutor(std::move(callback)); - }}; + }).detach(); } /*