Skip to content

Commit

Permalink
Detach thread in executeAsynchronously (RuntimeExecutor.h) (#31090)
Browse files Browse the repository at this point in the history
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 #31088

Fixes an invalid usage of std::thread's constructor

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://github.com/facebook/react-native/wiki/Changelog
-->

[General] [Fixed] - fixes usage of std::thread in runtime executor

Pull Request resolved: #31090

Reviewed By: sammy-SC

Differential Revision: D26783963

Pulled By: appden

fbshipit-source-id: fed4d072792aafa058dd742e8fce30a207f991c1
  • Loading branch information
asklar authored and facebook-github-bot committed Mar 4, 2021
1 parent 7e81c1d commit 75d9ba7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions ReactCommon/runtimeexecutor/ReactCommon/RuntimeExecutor.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ using RuntimeExecutor =
inline static void executeAsynchronously(
RuntimeExecutor const &runtimeExecutor,
std::function<void(jsi::Runtime &runtime)> &&callback) noexcept {
std::thread{[callback = std::move(callback), runtimeExecutor]() mutable {
std::thread([callback = std::move(callback), runtimeExecutor]() mutable {
runtimeExecutor(std::move(callback));
}};
}).detach();
}

/*
Expand Down

0 comments on commit 75d9ba7

Please sign in to comment.