Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

small refactor of EventBeat #47001

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,6 @@ void EventBeat::request() const {
isRequested_ = true;
}

void EventBeat::beat(jsi::Runtime& runtime) const {
if (!this->isRequested_) {
return;
}

isRequested_ = false;

if (beatCallback_) {
beatCallback_(runtime);
}
}

void EventBeat::induce() const {
// Default implementation does nothing.
}
Expand Down
21 changes: 6 additions & 15 deletions packages/react-native/ReactCommon/react/renderer/core/EventBeat.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@

#pragma once

#include <jsi/jsi.h>
#include <atomic>
#include <functional>
#include <memory>

namespace facebook::react {
namespace facebook::jsi {
class Runtime;
}

namespace facebook::react {
/*
* Event Beat serves two interleaving purposes: synchronization of event queues
* and ensuring that event dispatching happens on proper threads.
Expand Down Expand Up @@ -57,17 +59,6 @@ class EventBeat {
*/
virtual void request() const;

/*
* Induces the next beat to happen as soon as possible. If the method
* is called on the proper thread, the beat must happen synchronously.
* Subclasses might override this method to implement specific
* out-of-turn beat scheduling.
* Some types of Event Beats do not support inducing, hence the default
* implementation does nothing.
* Receiver might ignore the call if a beat was not requested.
*/
virtual void induce() const;

/*
* Sets the beat callback function.
* The callback is must be called on the proper thread.
Expand All @@ -76,10 +67,10 @@ class EventBeat {

protected:
/*
* Should be used by subclasses to send a beat.
* Induces the next beat to happen as soon as possible.
* Receiver might ignore the call if a beat was not requested.
*/
void beat(jsi::Runtime& runtime) const;
virtual void induce() const;

BeatCallback beatCallback_;
SharedOwnerBox ownerBox_;
Expand Down
Loading