Skip to content

Commit

Permalink
introduce flag to determine if turbomodule void method should run sync
Browse files Browse the repository at this point in the history
Differential Revision: D49521864

fbshipit-source-id: e74caf79db0c05a3bcbebda267ccb8b9ee9f6d0d
  • Loading branch information
philIip authored and facebook-github-bot committed Sep 21, 2023
1 parent f39952b commit 4f2ca11
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class JSI_EXPORT ObjCTurboModule : public TurboModule {
std::shared_ptr<CallInvoker> jsInvoker;
std::shared_ptr<NativeMethodCallInvoker> nativeMethodCallInvoker;
bool isSyncModule;
bool shouldVoidMethodsExecuteSync;
};

ObjCTurboModule(const InitParams &params);
Expand Down Expand Up @@ -112,6 +113,9 @@ class JSI_EXPORT ObjCTurboModule : public TurboModule {
// Does the NativeModule dispatch async methods to the JS thread?
const bool isSyncModule_;

// Should void methods execute synchronously?
const bool shouldVoidMethodsExecuteSync_;

/**
* TODO(ramanpreet):
* Investigate an optimization that'll let us get rid of this NSMutableDictionary.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,8 @@ id convertJSIValueToObjCObject(jsi::Runtime &runtime, const jsi::Value &value, s
: TurboModule(params.moduleName, params.jsInvoker),
instance_(params.instance),
nativeMethodCallInvoker_(params.nativeMethodCallInvoker),
isSyncModule_(params.isSyncModule)
isSyncModule_(params.isSyncModule),
shouldVoidMethodsExecuteSync_(params.shouldVoidMethodsExecuteSync)
{
}

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

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

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

0 comments on commit 4f2ca11

Please sign in to comment.