Skip to content

Commit

Permalink
delete AsynchronousEventBeat in favour of platform specific EventBeats (
Browse files Browse the repository at this point in the history
#47058)

Summary:
Pull Request resolved: #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
  • Loading branch information
sammy-SC authored and facebook-github-bot committed Oct 17, 2024
1 parent 7168a9d commit 9fe253d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
* LICENSE file in the root directory of this source tree.
*/

#include "AsynchronousEventBeat.h"
#include "AppleEventBeat.h"

#include <react/debug/react_native_assert.h>

namespace facebook::react {

AsynchronousEventBeat::AsynchronousEventBeat(
AppleEventBeat::AppleEventBeat(
RunLoopObserver::Unique uiRunLoopObserver,
RuntimeExecutor runtimeExecutor)
: EventBeat({}),
Expand All @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
4 changes: 2 additions & 2 deletions packages/react-native/React/Fabric/RCTSurfacePresenter.mm
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@
#import <react/renderer/componentregistry/ComponentDescriptorFactory.h>
#import <react/renderer/components/text/BaseTextProps.h>
#import <react/renderer/runtimescheduler/RuntimeScheduler.h>
#import <react/renderer/scheduler/AsynchronousEventBeat.h>
#import <react/renderer/scheduler/SchedulerToolbox.h>
#import <react/utils/ContextContainer.h>
#import <react/utils/CoreFeatures.h>
#import <react/utils/ManagedObjectWrapper.h>
#import "AppleEventBeat.h"

#import "PlatformRunLoopObserver.h"
#import "RCTConversions.h"
Expand Down Expand Up @@ -261,7 +261,7 @@ - (RCTScheduler *)_createScheduler
[runtimeExecutor](std::shared_ptr<EventBeat::OwnerBox> ownerBox) -> std::unique_ptr<EventBeat> {
auto runLoopObserver =
std::make_unique<const MainRunLoopObserver>(RunLoopObserver::Activity::BeforeWaiting, ownerBox->owner);
return std::make_unique<AsynchronousEventBeat>(std::move(runLoopObserver), runtimeExecutor);
return std::make_unique<AppleEventBeat>(std::move(runLoopObserver), runtimeExecutor);
};

RCTScheduler *scheduler = [[RCTScheduler alloc] initWithToolbox:toolbox];
Expand Down

0 comments on commit 9fe253d

Please sign in to comment.