1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 | #include "EventDispatcher.h"
|
9 |
|
10 | #include "BatchedEventQueue.h"
|
11 | #include "UnbatchedEventQueue.h"
|
12 |
|
13 | #define REACT_FABRIC_SYNC_EVENT_DISPATCHING_DISABLED
|
14 |
|
15 | namespace facebook {
|
16 | namespace react {
|
17 |
|
18 | EventDispatcher::EventDispatcher(
|
19 | const EventPipe &eventPipe,
|
20 | const EventBeatFactory &synchonousEventBeatFactory,
|
21 | const EventBeatFactory &asynchonousEventBeatFactory) {
|
22 |
|
23 | eventQueues_[(int)EventPriority::SynchronousUnbatched] =
|
24 | std::make_unique<UnbatchedEventQueue>(
|
25 | eventPipe, synchonousEventBeatFactory());
|
26 |
|
27 |
|
28 | eventQueues_[(int)EventPriority::SynchronousBatched] =
|
29 | std::make_unique<BatchedEventQueue>(
|
30 | eventPipe, synchonousEventBeatFactory());
|
31 |
|
32 |
|
33 | eventQueues_[(int)EventPriority::AsynchronousUnbatched] =
|
34 | std::make_unique<UnbatchedEventQueue>(
|
35 | eventPipe, asynchonousEventBeatFactory());
|
36 |
|
37 |
|
38 | eventQueues_[(int)EventPriority::AsynchronousBatched] =
|
39 | std::make_unique<BatchedEventQueue>(
|
40 | eventPipe, asynchonousEventBeatFactory());
|
41 | }
|
42 |
|
43 | void EventDispatcher::dispatchEvent(
|
44 | const RawEvent &rawEvent,
|
45 | EventPriority priority) const {
|
46 | #ifdef REACT_FABRIC_SYNC_EVENT_DISPATCHING_DISABLED
|
47 |
|
48 |
|
49 | if (priority == EventPriority::SynchronousUnbatched) {
|
50 | priority = EventPriority::AsynchronousUnbatched;
|
51 | }
|
52 |
|
53 | if (priority == EventPriority::SynchronousBatched) {
|
54 | priority = EventPriority::AsynchronousBatched;
|
55 | }
|
56 | #endif
|
57 |
|
58 | eventQueues_[(int)priority]->enqueueEvent(rawEvent);
|
59 | }
|
60 |
|
61 | }
|
62 | }
|