Skip to content

Commit

Permalink
hook up enable_sync_void_methods_ios mc param
Browse files Browse the repository at this point in the history
Summary:
Changelog: [Internal]

sync void execution is now hooked up to mc

Reviewed By: mdvacca

Differential Revision: D49854130

fbshipit-source-id: fb4241b11a80d44318b382e2757fe7fcbfba4fb1
  • Loading branch information
philIip authored and facebook-github-bot committed Oct 4, 2023
1 parent b401fab commit d0b2858
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 15 deletions.
34 changes: 21 additions & 13 deletions packages/react-native/React/Base/RCTBridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,47 +31,55 @@
*/
typedef NSArray<id<RCTBridgeModule>> * (^RCTBridgeModuleListProvider)(void);

RCT_EXTERN_C_BEGIN

/**
* This function returns the module name for a given class.
*/
RCT_EXTERN NSString *RCTBridgeModuleNameForClass(Class bridgeModuleClass);
NSString *RCTBridgeModuleNameForClass(Class bridgeModuleClass);

/**
* Experimental.
* Check/set if JSI-bound NativeModule is enabled. By default it's off.
*/
RCT_EXTERN BOOL RCTTurboModuleEnabled(void);
RCT_EXTERN void RCTEnableTurboModule(BOOL enabled);
BOOL RCTTurboModuleEnabled(void);
void RCTEnableTurboModule(BOOL enabled);

// Turn on TurboModule interop
RCT_EXTERN BOOL RCTTurboModuleInteropEnabled(void);
RCT_EXTERN void RCTEnableTurboModuleInterop(BOOL enabled);
BOOL RCTTurboModuleInteropEnabled(void);
void RCTEnableTurboModuleInterop(BOOL enabled);

// Turn on TurboModule interop's Bridge proxy
RCT_EXTERN BOOL RCTTurboModuleInteropBridgeProxyEnabled(void);
RCT_EXTERN void RCTEnableTurboModuleInteropBridgeProxy(BOOL enabled);
BOOL RCTTurboModuleInteropBridgeProxyEnabled(void);
void RCTEnableTurboModuleInteropBridgeProxy(BOOL enabled);

// Turn on TurboModule sync execution of void methods
BOOL RCTTurboModuleSyncVoidMethodsEnabled(void);
void RCTEnableTurboModuleSyncVoidMethods(BOOL enabled);

typedef enum {
kRCTBridgeProxyLoggingLevelNone,
kRCTBridgeProxyLoggingLevelWarning,
kRCTBridgeProxyLoggingLevelError,
} RCTBridgeProxyLoggingLevel;

RCT_EXTERN RCTBridgeProxyLoggingLevel RCTTurboModuleInteropBridgeProxyLogLevel(void);
RCT_EXTERN void RCTSetTurboModuleInteropBridgeProxyLogLevel(RCTBridgeProxyLoggingLevel logLevel);
RCTBridgeProxyLoggingLevel RCTTurboModuleInteropBridgeProxyLogLevel(void);
void RCTSetTurboModuleInteropBridgeProxyLogLevel(RCTBridgeProxyLoggingLevel logLevel);

// Route all TurboModules through TurboModule interop
RCT_EXTERN BOOL RCTTurboModuleInteropForAllTurboModulesEnabled(void);
RCT_EXTERN void RCTEnableTurboModuleInteropForAllTurboModules(BOOL enabled);
BOOL RCTTurboModuleInteropForAllTurboModulesEnabled(void);
void RCTEnableTurboModuleInteropForAllTurboModules(BOOL enabled);

typedef enum {
kRCTGlobalScope,
kRCTGlobalScopeUsingRetainJSCallback,
kRCTTurboModuleManagerScope,
} RCTTurboModuleCleanupMode;

RCT_EXTERN RCTTurboModuleCleanupMode RCTGetTurboModuleCleanupMode(void);
RCT_EXTERN void RCTSetTurboModuleCleanupMode(RCTTurboModuleCleanupMode mode);
RCTTurboModuleCleanupMode RCTGetTurboModuleCleanupMode(void);
void RCTSetTurboModuleCleanupMode(RCTTurboModuleCleanupMode mode);

RCT_EXTERN_C_END

/**
* Async batched bridge used to communicate with the JavaScript application.
Expand Down
11 changes: 11 additions & 0 deletions packages/react-native/React/Base/RCTBridge.mm
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,17 @@ void RCTEnableTurboModuleInteropForAllTurboModules(BOOL enabled)
useTurboModuleInteropForAllTurboModules = enabled;
}

// Turn on TurboModule sync execution of void methods
static BOOL gTurboModuleEnableSyncVoidMethods = NO;
BOOL RCTTurboModuleSyncVoidMethodsEnabled(void)
{
return gTurboModuleEnableSyncVoidMethods;
}
void RCTEnableTurboModuleSyncVoidMethods(BOOL enabled)
{
gTurboModuleEnableSyncVoidMethods = enabled;
}

@interface RCTBridge () <RCTReloadListener>
@end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ - (instancetype)initWithBridgeProxy:(RCTBridgeProxy *)bridgeProxy
.jsInvoker = _jsInvoker,
.nativeMethodCallInvoker = nativeMethodCallInvoker,
.isSyncModule = methodQueue == RCTJSThread,
.shouldVoidMethodsExecuteSync = false,
.shouldVoidMethodsExecuteSync = RCTTurboModuleSyncVoidMethodsEnabled(),
};

auto turboModule = [(id<RCTTurboModule>)module getTurboModule:params];
Expand Down Expand Up @@ -438,7 +438,7 @@ - (instancetype)initWithBridgeProxy:(RCTBridgeProxy *)bridgeProxy
.jsInvoker = _jsInvoker,
.nativeMethodCallInvoker = std::move(nativeMethodCallInvoker),
.isSyncModule = methodQueue == RCTJSThread,
.shouldVoidMethodsExecuteSync = false,
.shouldVoidMethodsExecuteSync = RCTTurboModuleSyncVoidMethodsEnabled(),
};

auto turboModule = std::make_shared<ObjCInteropTurboModule>(params);
Expand Down

0 comments on commit d0b2858

Please sign in to comment.