File tree Expand file tree Collapse file tree
ReactCommon/react/renderer/runtimescheduler Expand file tree Collapse file tree Original file line number Diff line number Diff line change 9494 */
9595- (UIViewController *)createRootViewController ;
9696
97+ // / This method controls whether the App will use RuntimeScheduler. Only applicable in the legacy architecture.
98+ // /
99+ // / @return: `YES` to use RuntimeScheduler, `NO` to use JavaScript scheduler. The default value is `YES`.
100+ - (BOOL )runtimeSchedulerEnabled ;
101+
97102#if RCT_NEW_ARCH_ENABLED
98103
99104// / The TurboModule manager
Original file line number Diff line number Diff line change @@ -134,18 +134,26 @@ - (UIViewController *)createRootViewController
134134 return [UIViewController new ];
135135}
136136
137+ - (BOOL )runtimeSchedulerEnabled
138+ {
139+ return YES ;
140+ }
141+
137142#pragma mark - RCTCxxBridgeDelegate
138143- (std::unique_ptr<facebook::react::JSExecutorFactory>)jsExecutorFactoryForBridge : (RCTBridge *)bridge
139144{
140- _runtimeScheduler = std::make_shared<facebook::react::RuntimeScheduler>(RCTRuntimeExecutorFromBridge (bridge));
141145#if RCT_NEW_ARCH_ENABLED
146+ _runtimeScheduler = std::make_shared<facebook::react::RuntimeScheduler>(RCTRuntimeExecutorFromBridge (bridge));
142147 std::shared_ptr<facebook::react::CallInvoker> callInvoker =
143148 std::make_shared<facebook::react::RuntimeSchedulerCallInvoker>(_runtimeScheduler);
144149 self.turboModuleManager = [[RCTTurboModuleManager alloc ] initWithBridge: bridge delegate: self jsInvoker: callInvoker];
145150 _contextContainer->erase (" RuntimeScheduler" );
146151 _contextContainer->insert (" RuntimeScheduler" , _runtimeScheduler);
147152 return RCTAppSetupDefaultJsExecutorFactory (bridge, self.turboModuleManager , _runtimeScheduler);
148153#else
154+ if (self.runtimeSchedulerEnabled ) {
155+ _runtimeScheduler = std::make_shared<facebook::react::RuntimeScheduler>(RCTRuntimeExecutorFromBridge (bridge));
156+ }
149157 return RCTAppSetupJsExecutorFactoryForOldArch (bridge, _runtimeScheduler);
150158#endif
151159}
Original file line number Diff line number Diff line change @@ -19,11 +19,17 @@ struct TaskWrapper : public jsi::HostObject {
1919 std::shared_ptr<Task> task;
2020};
2121
22+ struct TaskWrapper : public jsi ::HostObject {
23+ TaskWrapper (std::shared_ptr<Task> const &task) : task(task) {}
24+
25+ std::shared_ptr<Task> task;
26+ };
27+
2228inline static jsi::Value valueFromTask (
2329 jsi::Runtime &runtime,
2430 std::shared_ptr<Task> task) {
2531 return jsi::Object::createFromHostObject (
26- runtime, std::make_shared<TaskWrapper>(task));
32+ runtime, std::make_shared<TaskWrapper>(task));
2733}
2834
2935inline static std::shared_ptr<Task> taskFromValue (
You can’t perform that action at this time.
0 commit comments