mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Fabric: Removing scheduling to JS thread from EventBeatManager.java
Summary: The C++ counterpart of EventBeatManager uses RuntimeExecutor for that, so it's redundant to do that in EventBeatManager.java. Changelog: [Internal] Fabric-specific internal change. Reviewed By: sammy-SC Differential Revision: D18307657 fbshipit-source-id: 65823b25d691a56540247d317e3c0e86685150c8
This commit is contained in:
committed by
Facebook Github Bot
parent
7ad862eaba
commit
50b171ff8b
@@ -30,7 +30,7 @@ public class EventBeatManager implements BatchEventDispatchedListener {
|
||||
|
||||
private static native HybridData initHybrid();
|
||||
|
||||
private native void beat();
|
||||
private native void tick();
|
||||
|
||||
public EventBeatManager(@NonNull ReactApplicationContext reactApplicationContext) {
|
||||
mHybridData = initHybrid();
|
||||
@@ -39,23 +39,6 @@ public class EventBeatManager implements BatchEventDispatchedListener {
|
||||
|
||||
@Override
|
||||
public void onBatchEventDispatched() {
|
||||
dispatchEventsAsync();
|
||||
}
|
||||
|
||||
/**
|
||||
* Induce a beat in the AsyncEventBeat, calling the JNI method {@link #beat()} in the JS thread.
|
||||
*/
|
||||
private void dispatchEventsAsync() {
|
||||
if (mReactApplicationContext.isOnJSQueueThread()) {
|
||||
beat();
|
||||
} else {
|
||||
mReactApplicationContext.runOnJSQueueThread(
|
||||
new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
beat();
|
||||
}
|
||||
});
|
||||
}
|
||||
tick();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ void EventBeatManager::unregisterEventBeat(EventBeat* eventBeat) const {
|
||||
registeredEventBeats_.erase(eventBeat);
|
||||
}
|
||||
|
||||
void EventBeatManager::beat() {
|
||||
void EventBeatManager::tick() {
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
|
||||
for (const auto eventBeat : registeredEventBeats_) {
|
||||
@@ -50,7 +50,7 @@ void EventBeatManager::beat() {
|
||||
void EventBeatManager::registerNatives() {
|
||||
registerHybrid({
|
||||
makeNativeMethod("initHybrid", EventBeatManager::initHybrid),
|
||||
makeNativeMethod("beat", EventBeatManager::beat),
|
||||
makeNativeMethod("tick", EventBeatManager::tick),
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -34,11 +34,14 @@ class EventBeatManager : public jni::HybridClass<EventBeatManager> {
|
||||
|
||||
void unregisterEventBeat(EventBeat* eventBeat) const;
|
||||
|
||||
void beat();
|
||||
|
||||
EventBeatManager(jni::alias_ref<EventBeatManager::jhybriddata> jhybridobject);
|
||||
|
||||
private:
|
||||
/*
|
||||
* Called by Java counterpart at the end of every run loop tick.
|
||||
*/
|
||||
void tick();
|
||||
|
||||
RuntimeExecutor runtimeExecutor_;
|
||||
|
||||
jni::alias_ref<EventBeatManager::jhybriddata> jhybridobject_;
|
||||
|
||||
Reference in New Issue
Block a user