diff --git a/packages/react-native/React/Base/RCTBridge.h b/packages/react-native/React/Base/RCTBridge.h index 68651edb771a6b..846e17fdb1104e 100644 --- a/packages/react-native/React/Base/RCTBridge.h +++ b/packages/react-native/React/Base/RCTBridge.h @@ -57,6 +57,10 @@ void RCTEnableTurboModuleInteropBridgeProxy(BOOL enabled); BOOL RCTTurboModuleSyncVoidMethodsEnabled(void); void RCTEnableTurboModuleSyncVoidMethods(BOOL enabled); +// Use a shared queue for executing module methods +BOOL RCTTurboModuleSharedQueueEnabled(void); +void RCTEnableTurboModuleSharedQueue(BOOL enabled); + typedef enum { kRCTBridgeProxyLoggingLevelNone, kRCTBridgeProxyLoggingLevelWarning, diff --git a/packages/react-native/React/Base/RCTBridge.mm b/packages/react-native/React/Base/RCTBridge.mm index d0598e621e22f2..a18b43861cbabd 100644 --- a/packages/react-native/React/Base/RCTBridge.mm +++ b/packages/react-native/React/Base/RCTBridge.mm @@ -150,6 +150,18 @@ void RCTEnableTurboModuleSyncVoidMethods(BOOL enabled) gTurboModuleEnableSyncVoidMethods = enabled; } +// Use a shared queue for executing module methods +static BOOL gTurboModuleEnableSharedQueue = NO; +BOOL RCTTurboModuleSharedQueueEnabled(void) +{ + return gTurboModuleEnableSharedQueue; +} + +void RCTEnableTurboModuleSharedQueue(BOOL enabled) +{ + gTurboModuleEnableSharedQueue = enabled; +} + @interface RCTBridge () @end diff --git a/packages/react-native/ReactCommon/react/nativemodule/core/platform/ios/ReactCommon/RCTTurboModuleManager.mm b/packages/react-native/ReactCommon/react/nativemodule/core/platform/ios/ReactCommon/RCTTurboModuleManager.mm index 5feb7b578dce74..ad8fadd04b1ef4 100644 --- a/packages/react-native/ReactCommon/react/nativemodule/core/platform/ios/ReactCommon/RCTTurboModuleManager.mm +++ b/packages/react-native/ReactCommon/react/nativemodule/core/platform/ios/ReactCommon/RCTTurboModuleManager.mm @@ -224,7 +224,7 @@ - (instancetype)initWithBridge:(RCTBridge *)bridge _bridgeProxy = bridgeProxy; _bridgeModuleDecorator = bridgeModuleDecorator; _invalidating = false; - _enableSharedModuleQueue = NO; + _enableSharedModuleQueue = RCTTurboModuleSharedQueueEnabled(); if (_enableSharedModuleQueue) { _sharedModuleQueue = dispatch_queue_create("com.meta.react.turbomodulemanager.queue", DISPATCH_QUEUE_SERIAL);