Remove v1 event coalescing

Summary:
Changelog: [internal]

Old event coalescing isn't used anymore and there haven't been any problems with the new one.

Reviewed By: shergin

Differential Revision: D25701311

fbshipit-source-id: 359f0361edffa22130cfa8322038acdbe26fd599
This commit is contained in:
Samuel Susla
2021-01-04 04:12:30 -08:00
committed by Facebook GitHub Bot
parent e2033c5b7b
commit 1bafd0086f
5 changed files with 24 additions and 47 deletions
@@ -13,10 +13,8 @@ namespace react {
BatchedEventQueue::BatchedEventQueue(
EventPipe eventPipe,
StatePipe statePipe,
std::unique_ptr<EventBeat> eventBeat,
bool enableV2EventCoalescing)
: EventQueue(eventPipe, statePipe, std::move(eventBeat)),
enableV2EventCoalescing_(enableV2EventCoalescing) {}
std::unique_ptr<EventBeat> eventBeat)
: EventQueue(eventPipe, statePipe, std::move(eventBeat)) {}
void BatchedEventQueue::onEnqueue() const {
EventQueue::onEnqueue();
@@ -28,38 +26,26 @@ void BatchedEventQueue::enqueueUniqueEvent(RawEvent const &rawEvent) const {
{
std::lock_guard<std::mutex> lock(queueMutex_);
if (enableV2EventCoalescing_) {
auto repeatedEvent = eventQueue_.rend();
auto repeatedEvent = eventQueue_.rend();
for (auto it = eventQueue_.rbegin(); it != eventQueue_.rend(); ++it) {
if (it->type == rawEvent.type &&
it->eventTarget == rawEvent.eventTarget) {
repeatedEvent = it;
break;
} else if (it->eventTarget == rawEvent.eventTarget) {
// It is necessary to maintain order of different event types
// for the same target. If the same target has event types A1, B1
// in the event queue and event A2 occurs. A1 has to stay in the
// queue.
break;
}
}
if (repeatedEvent == eventQueue_.rend()) {
eventQueue_.push_back(rawEvent);
} else {
*repeatedEvent = std::move(rawEvent);
}
} else {
if (!eventQueue_.empty()) {
auto const position = eventQueue_.back();
if (position.type == rawEvent.type &&
position.eventTarget == rawEvent.eventTarget) {
eventQueue_.pop_back();
}
for (auto it = eventQueue_.rbegin(); it != eventQueue_.rend(); ++it) {
if (it->type == rawEvent.type &&
it->eventTarget == rawEvent.eventTarget) {
repeatedEvent = it;
break;
} else if (it->eventTarget == rawEvent.eventTarget) {
// It is necessary to maintain order of different event types
// for the same target. If the same target has event types A1, B1
// in the event queue and event A2 occurs. A1 has to stay in the
// queue.
break;
}
}
if (repeatedEvent == eventQueue_.rend()) {
eventQueue_.push_back(rawEvent);
} else {
*repeatedEvent = std::move(rawEvent);
}
}
@@ -21,8 +21,7 @@ class BatchedEventQueue final : public EventQueue {
BatchedEventQueue(
EventPipe eventPipe,
StatePipe statePipe,
std::unique_ptr<EventBeat> eventBeat,
bool enableV2EventCoalescing);
std::unique_ptr<EventBeat> eventBeat);
void onEnqueue() const override;
@@ -32,9 +31,6 @@ class BatchedEventQueue final : public EventQueue {
* Can be called on any thread.
*/
void enqueueUniqueEvent(const RawEvent &rawEvent) const;
private:
bool const enableV2EventCoalescing_;
};
} // namespace react
@@ -21,8 +21,7 @@ EventDispatcher::EventDispatcher(
StatePipe const &statePipe,
EventBeat::Factory const &synchonousEventBeatFactory,
EventBeat::Factory const &asynchonousEventBeatFactory,
EventBeat::SharedOwnerBox const &ownerBox,
bool enableV2EventCoalescing)
EventBeat::SharedOwnerBox const &ownerBox)
: synchronousUnbatchedQueue_(std::make_unique<UnbatchedEventQueue>(
eventPipe,
statePipe,
@@ -30,8 +29,7 @@ EventDispatcher::EventDispatcher(
synchronousBatchedQueue_(std::make_unique<BatchedEventQueue>(
eventPipe,
statePipe,
synchonousEventBeatFactory(ownerBox),
enableV2EventCoalescing)),
synchonousEventBeatFactory(ownerBox))),
asynchronousUnbatchedQueue_(std::make_unique<UnbatchedEventQueue>(
eventPipe,
statePipe,
@@ -39,8 +37,7 @@ EventDispatcher::EventDispatcher(
asynchronousBatchedQueue_(std::make_unique<BatchedEventQueue>(
eventPipe,
statePipe,
asynchonousEventBeatFactory(ownerBox),
enableV2EventCoalescing)) {}
asynchonousEventBeatFactory(ownerBox))) {}
void EventDispatcher::dispatchEvent(
RawEvent const &rawEvent,
@@ -37,8 +37,7 @@ class EventDispatcher {
StatePipe const &statePipe,
EventBeat::Factory const &synchonousEventBeatFactory,
EventBeat::Factory const &asynchonousEventBeatFactory,
EventBeat::SharedOwnerBox const &ownerBox,
bool enableV2EventCoalescing);
EventBeat::SharedOwnerBox const &ownerBox);
/*
* Dispatches a raw event with given priority using event-delivery pipe.
@@ -67,8 +67,7 @@ Scheduler::Scheduler(
statePipe,
schedulerToolbox.synchronousEventBeatFactory,
schedulerToolbox.asynchronousEventBeatFactory,
eventOwnerBox,
reactNativeConfig_->getBool("react_fabric:enable_v2_event_coalescing"));
eventOwnerBox);
// Casting to `std::shared_ptr<EventDispatcher const>`.
auto eventDispatcher =