void DeviceEventDispatcherBase::notifyControllers() { { TemporaryChange<bool> changeIsDispatching(m_isDispatching, true); // Don't notify controllers removed or added during event dispatch. size_t size = m_controllers.size(); for (size_t i = 0; i < size; ++i) { if (m_controllers[i]) m_controllers[i]->didUpdateData(); } } if (m_needsPurge) purgeControllers(); }
void PlatformEventDispatcher::notifyControllers() { if (m_controllers.isEmpty()) return; { TemporaryChange<bool> changeIsDispatching(m_isDispatching, true); // HashSet m_controllers can be updated during an iteration, and it stops the iteration. // Thus we store it into a Vector to access all elements. WillBeHeapVector<RawPtrWillBeMember<PlatformEventController>> snapshotVector; copyToVector(m_controllers, snapshotVector); for (PlatformEventController* controller : snapshotVector) { if (m_controllers.contains(controller)) controller->didUpdateData(); } } if (m_controllers.isEmpty()) { stopListening(); m_isListening = false; } }