Skip to content

Commit

Permalink
hook up gating to shared native module queue (facebook#41043)
Browse files Browse the repository at this point in the history
Summary:

Changelog: [Internal]

in this change, we create an config pipeline to set `_enableSharedModuleQueue` in TMM

Differential Revision: D50398636
  • Loading branch information
philIip authored and facebook-github-bot committed Oct 18, 2023
1 parent c0b1b16 commit 68d67d9
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
4 changes: 4 additions & 0 deletions packages/react-native/React/Base/RCTBridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
12 changes: 12 additions & 0 deletions packages/react-native/React/Base/RCTBridge.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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 () <RCTReloadListener>
@end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 68d67d9

Please sign in to comment.