From 9fe253d6772c514264be100b259757e86af4763d Mon Sep 17 00:00:00 2001 From: Samuel Susla Date: Thu, 17 Oct 2024 11:51:22 -0700 Subject: [PATCH] delete AsynchronousEventBeat in favour of platform specific EventBeats (#47058) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/47058 changelog: [internal] # Goal of this stack: Centralise event beat logic into EventBeat class inside react-native-github. Subclasses should only override EventBeat::request and EventBeat::induce. Reviewed By: christophpurrer Differential Revision: D64291889 fbshipit-source-id: fa46e2c5246e1a9a1b5f3bd02e5c0efa562188e9 --- .../Fabric/AppleEventBeat.cpp} | 8 ++++---- .../Fabric/AppleEventBeat.h} | 5 ++--- packages/react-native/React/Fabric/RCTSurfacePresenter.mm | 4 ++-- 3 files changed, 8 insertions(+), 9 deletions(-) rename packages/react-native/{ReactCommon/react/renderer/scheduler/AsynchronousEventBeat.cpp => React/Fabric/AppleEventBeat.cpp} (88%) rename packages/react-native/{ReactCommon/react/renderer/scheduler/AsynchronousEventBeat.h => React/Fabric/AppleEventBeat.h} (88%) diff --git a/packages/react-native/ReactCommon/react/renderer/scheduler/AsynchronousEventBeat.cpp b/packages/react-native/React/Fabric/AppleEventBeat.cpp similarity index 88% rename from packages/react-native/ReactCommon/react/renderer/scheduler/AsynchronousEventBeat.cpp rename to packages/react-native/React/Fabric/AppleEventBeat.cpp index 30ab47eea42..8038778a1ca 100644 --- a/packages/react-native/ReactCommon/react/renderer/scheduler/AsynchronousEventBeat.cpp +++ b/packages/react-native/React/Fabric/AppleEventBeat.cpp @@ -5,13 +5,13 @@ * LICENSE file in the root directory of this source tree. */ -#include "AsynchronousEventBeat.h" +#include "AppleEventBeat.h" #include namespace facebook::react { -AsynchronousEventBeat::AsynchronousEventBeat( +AppleEventBeat::AppleEventBeat( RunLoopObserver::Unique uiRunLoopObserver, RuntimeExecutor runtimeExecutor) : EventBeat({}), @@ -21,14 +21,14 @@ AsynchronousEventBeat::AsynchronousEventBeat( uiRunLoopObserver_->enable(); } -void AsynchronousEventBeat::activityDidChange( +void AppleEventBeat::activityDidChange( const RunLoopObserver::Delegate* delegate, RunLoopObserver::Activity /*activity*/) const noexcept { react_native_assert(delegate == this); induce(); } -void AsynchronousEventBeat::induce() const { +void AppleEventBeat::induce() const { if (!isRequested_ || isBeatCallbackScheduled_) { return; } diff --git a/packages/react-native/ReactCommon/react/renderer/scheduler/AsynchronousEventBeat.h b/packages/react-native/React/Fabric/AppleEventBeat.h similarity index 88% rename from packages/react-native/ReactCommon/react/renderer/scheduler/AsynchronousEventBeat.h rename to packages/react-native/React/Fabric/AppleEventBeat.h index af877980b00..5a240a7bbd1 100644 --- a/packages/react-native/ReactCommon/react/renderer/scheduler/AsynchronousEventBeat.h +++ b/packages/react-native/React/Fabric/AppleEventBeat.h @@ -18,10 +18,9 @@ namespace facebook::react { * The beat is called on `RuntimeExecutor`'s thread induced by the UI thread * event loop. */ -class AsynchronousEventBeat : public EventBeat, - public RunLoopObserver::Delegate { +class AppleEventBeat : public EventBeat, public RunLoopObserver::Delegate { public: - AsynchronousEventBeat( + AppleEventBeat( RunLoopObserver::Unique uiRunLoopObserver, RuntimeExecutor runtimeExecutor); diff --git a/packages/react-native/React/Fabric/RCTSurfacePresenter.mm b/packages/react-native/React/Fabric/RCTSurfacePresenter.mm index 5cdaec9dd65..5290f850a3e 100644 --- a/packages/react-native/React/Fabric/RCTSurfacePresenter.mm +++ b/packages/react-native/React/Fabric/RCTSurfacePresenter.mm @@ -31,11 +31,11 @@ #import #import #import -#import #import #import #import #import +#import "AppleEventBeat.h" #import "PlatformRunLoopObserver.h" #import "RCTConversions.h" @@ -261,7 +261,7 @@ using namespace facebook::react; [runtimeExecutor](std::shared_ptr ownerBox) -> std::unique_ptr { auto runLoopObserver = std::make_unique(RunLoopObserver::Activity::BeforeWaiting, ownerBox->owner); - return std::make_unique(std::move(runLoopObserver), runtimeExecutor); + return std::make_unique(std::move(runLoopObserver), runtimeExecutor); }; RCTScheduler *scheduler = [[RCTScheduler alloc] initWithToolbox:toolbox];