Fabric: Simplified relationship between RawEvent and EventEmitter

Summary: Instead of relying on explicit `RawEventDispatchable` function, we simply check the existence of the `weak_ptr` to `EventTarget`. This is efficient and sufficient because only an EventEmitter retains an associated EventTarget.

Reviewed By: mdvacca

Differential Revision: D9764858

fbshipit-source-id: 4ac25d925f189d0f8b9002e52388fd51629934a8
This commit is contained in:
Valentin Shergin
2018-09-13 22:56:06 -07:00
committed by Facebook Github Bot
parent b6e42517e5
commit 93dd790cad
5 changed files with 9 additions and 39 deletions

View File

@@ -39,10 +39,10 @@ void EventQueue::onBeat() const {
{
std::lock_guard<std::recursive_mutex> lock(EventEmitter::DispatchMutex());
for (const auto &event : queue) {
auto eventTarget = event.eventTarget.lock();
eventPipe_(
eventTarget && event.isDispatchable() ? eventTarget.get() : nullptr,
event.eventTarget.lock().get(),
event.type,
event.payload
);