Skip to content

Commit b3a8eba

Browse files
sammy-SCfacebook-github-bot
authored andcommitted
merge BatchedEventQueue into EventQueue (#43438)
Summary: Pull Request resolved: #43438 changelog: [internal] EventQueue can now be merged with BatchedEventQueue since there isn't anything else subclassing it. Reviewed By: javache Differential Revision: D54687859 fbshipit-source-id: f646583db0e46789b667f8d79d24d0cf9d7fc00c
1 parent 7af288e commit b3a8eba

File tree

6 files changed

+13
-59
lines changed

6 files changed

+13
-59
lines changed

packages/react-native/ReactCommon/react/renderer/core/BatchedEventQueue.cpp

Lines changed: 0 additions & 20 deletions
This file was deleted.

packages/react-native/ReactCommon/react/renderer/core/BatchedEventQueue.h

Lines changed: 0 additions & 28 deletions
This file was deleted.

packages/react-native/ReactCommon/react/renderer/core/EventDispatcher.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#include <react/renderer/core/StateUpdate.h>
1111
#include "EventLogger.h"
1212

13-
#include "BatchedEventQueue.h"
13+
#include "EventQueue.h"
1414
#include "RawEvent.h"
1515

1616
namespace facebook::react {
@@ -20,9 +20,8 @@ EventDispatcher::EventDispatcher(
2020
const EventBeat::Factory& synchonousEventBeatFactory,
2121
const EventBeat::Factory& asynchronousEventBeatFactory,
2222
const EventBeat::SharedOwnerBox& ownerBox)
23-
: asynchronousBatchedQueue_(std::make_unique<BatchedEventQueue>(
24-
eventProcessor,
25-
asynchronousEventBeatFactory(ownerBox))) {}
23+
: eventQueue_(
24+
EventQueue(eventProcessor, asynchronousEventBeatFactory(ownerBox))) {}
2625

2726
void EventDispatcher::dispatchEvent(RawEvent&& rawEvent) const {
2827
// Allows the event listener to interrupt default event dispatch
@@ -34,19 +33,19 @@ void EventDispatcher::dispatchEvent(RawEvent&& rawEvent) const {
3433
if (eventLogger != nullptr) {
3534
rawEvent.loggingTag = eventLogger->onEventStart(rawEvent.type);
3635
}
37-
asynchronousBatchedQueue_->enqueueEvent(std::move(rawEvent));
36+
eventQueue_.enqueueEvent(std::move(rawEvent));
3837
}
3938

4039
void EventDispatcher::dispatchStateUpdate(StateUpdate&& stateUpdate) const {
41-
asynchronousBatchedQueue_->enqueueStateUpdate(std::move(stateUpdate));
40+
eventQueue_.enqueueStateUpdate(std::move(stateUpdate));
4241
}
4342

4443
void EventDispatcher::dispatchUniqueEvent(RawEvent&& rawEvent) const {
4544
// Allows the event listener to interrupt default event dispatch
4645
if (eventListeners_.willDispatchEvent(rawEvent)) {
4746
return;
4847
}
49-
asynchronousBatchedQueue_->enqueueUniqueEvent(std::move(rawEvent));
48+
eventQueue_.enqueueUniqueEvent(std::move(rawEvent));
5049
}
5150

5251
void EventDispatcher::addListener(

packages/react-native/ReactCommon/react/renderer/core/EventDispatcher.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77

88
#pragma once
99

10-
#include <react/renderer/core/BatchedEventQueue.h>
1110
#include <react/renderer/core/EventBeat.h>
1211
#include <react/renderer/core/EventListener.h>
12+
#include <react/renderer/core/EventQueue.h>
1313
#include <react/renderer/core/EventQueueProcessor.h>
1414
#include <react/renderer/core/StateUpdate.h>
1515

@@ -62,7 +62,7 @@ class EventDispatcher {
6262
const std::shared_ptr<const EventListener>& listener) const;
6363

6464
private:
65-
std::unique_ptr<BatchedEventQueue> asynchronousBatchedQueue_;
65+
EventQueue eventQueue_;
6666

6767
mutable EventListenerContainer eventListeners_;
6868
};

packages/react-native/ReactCommon/react/renderer/core/EventQueue.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ void EventQueue::enqueueStateUpdate(StateUpdate&& stateUpdate) const {
7575
onEnqueue();
7676
}
7777

78+
void EventQueue::onEnqueue() const {
79+
eventBeat_->request();
80+
}
81+
7882
void EventQueue::onBeat(jsi::Runtime& runtime) const {
7983
flushStateUpdates();
8084
flushEvents(runtime);

packages/react-native/ReactCommon/react/renderer/core/EventQueue.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ class EventQueue {
2828
EventQueue(
2929
EventQueueProcessor eventProcessor,
3030
std::unique_ptr<EventBeat> eventBeat);
31-
virtual ~EventQueue() = default;
3231

3332
/*
3433
* Enqueues and (probably later) dispatch a given event.
@@ -55,7 +54,7 @@ class EventQueue {
5554
* Override in subclasses to trigger beat `request` and/or beat `induce`.
5655
* Default implementation does nothing.
5756
*/
58-
virtual void onEnqueue() const = 0;
57+
void onEnqueue() const;
5958
void onBeat(jsi::Runtime& runtime) const;
6059

6160
void flushEvents(jsi::Runtime& runtime) const;

0 commit comments

Comments
 (0)