mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Fabric: Fixing executeSynchronouslyOnSameThread_CAN_DEADLOCK
Summary: In D20551411 we (I) replaced `std::mutex` with `std::recursive_mutex` in `executeSynchronouslyOnSameThread_CAN_DEADLOCK` in order to support synchronous `RuntimeExecutor`. It turned out that the idea was cool but totally incorrect. Quite obviously, double locking recursive mutex on the same thread does nothing, so the whole setup does not work at all. Changelog: [Internal] Fabric-specific internal change. Reviewed By: sammy-SC Differential Revision: D21328072 fbshipit-source-id: 7f1f81de61c36adb167fe624ada3bd71913bdf7c
This commit is contained in:
committed by
Facebook GitHub Bot
parent
780f06cd47
commit
56592c500f
@@ -78,12 +78,10 @@ inline static void executeSynchronouslyOnSameThread_CAN_DEADLOCK(
|
||||
std::function<void(jsi::Runtime &runtime)> &&callback) noexcept {
|
||||
// Note: We need the third mutex to get back to the main thread before
|
||||
// the lambda is finished (because all mutexes are allocated on the stack).
|
||||
// We use `recursive_mutex` here to not deadlock in case if a
|
||||
// `RuntimeExecutor` executes the callback synchronously.
|
||||
|
||||
std::recursive_mutex mutex1;
|
||||
std::recursive_mutex mutex2;
|
||||
std::recursive_mutex mutex3;
|
||||
std::mutex mutex1;
|
||||
std::mutex mutex2;
|
||||
std::mutex mutex3;
|
||||
|
||||
mutex1.lock();
|
||||
mutex2.lock();
|
||||
|
||||
Reference in New Issue
Block a user