|
8 | 8 | #include "TimerManager.h" |
9 | 9 |
|
10 | 10 | #include <cxxreact/TraceSection.h> |
11 | | -#include <react/featureflags/ReactNativeFeatureFlags.h> |
12 | 11 |
|
13 | 12 | #include <cmath> |
14 | 13 | #include <utility> |
@@ -62,41 +61,6 @@ void TimerManager::setRuntimeExecutor( |
62 | 61 | runtimeExecutor_ = std::move(runtimeExecutor); |
63 | 62 | } |
64 | 63 |
|
65 | | -TimerHandle TimerManager::createReactNativeMicrotask( |
66 | | - jsi::Function&& callback, |
67 | | - std::vector<jsi::Value>&& args) { |
68 | | - // Get the id for the callback. |
69 | | - TimerHandle timerID = timerIndex_++; |
70 | | - timers_.emplace( |
71 | | - std::piecewise_construct, |
72 | | - std::forward_as_tuple(timerID), |
73 | | - std::forward_as_tuple( |
74 | | - std::move(callback), std::move(args), /* repeat */ false)); |
75 | | - |
76 | | - reactNativeMicrotasksQueue_.push_back(timerID); |
77 | | - return timerID; |
78 | | -} |
79 | | - |
80 | | -void TimerManager::callReactNativeMicrotasks(jsi::Runtime& runtime) { |
81 | | - std::vector<TimerHandle> reactNativeMicrotasksQueue; |
82 | | - while (!reactNativeMicrotasksQueue_.empty()) { |
83 | | - reactNativeMicrotasksQueue.clear(); |
84 | | - reactNativeMicrotasksQueue.swap(reactNativeMicrotasksQueue_); |
85 | | - |
86 | | - for (auto reactNativeMicrotaskID : reactNativeMicrotasksQueue) { |
87 | | - // ReactNativeMicrotasks can clear other scheduled reactNativeMicrotasks. |
88 | | - auto it = timers_.find(reactNativeMicrotaskID); |
89 | | - if (it != timers_.end()) { |
90 | | - it->second.invoke(runtime); |
91 | | - |
92 | | - // Invoking a timer has the potential to delete it. Do not re-use the |
93 | | - // existing iterator to erase it from the map. |
94 | | - timers_.erase(reactNativeMicrotaskID); |
95 | | - } |
96 | | - } |
97 | | - } |
98 | | -} |
99 | | - |
100 | 64 | TimerHandle TimerManager::createTimer( |
101 | 65 | jsi::Function&& callback, |
102 | 66 | std::vector<jsi::Value>&& args, |
@@ -156,24 +120,6 @@ TimerHandle TimerManager::createRecurringTimer( |
156 | 120 | return timerID; |
157 | 121 | } |
158 | 122 |
|
159 | | -void TimerManager::deleteReactNativeMicrotask( |
160 | | - jsi::Runtime& runtime, |
161 | | - TimerHandle timerHandle) { |
162 | | - if (timerHandle < 0) { |
163 | | - throw jsi::JSError( |
164 | | - runtime, "clearReactNativeMicrotask was called with an invalid handle"); |
165 | | - } |
166 | | - |
167 | | - auto it = std::find( |
168 | | - reactNativeMicrotasksQueue_.begin(), |
169 | | - reactNativeMicrotasksQueue_.end(), |
170 | | - timerHandle); |
171 | | - if (it != reactNativeMicrotasksQueue_.end()) { |
172 | | - reactNativeMicrotasksQueue_.erase(it); |
173 | | - timers_.erase(timerHandle); |
174 | | - } |
175 | | -} |
176 | | - |
177 | 123 | void TimerManager::deleteTimer(jsi::Runtime& runtime, TimerHandle timerHandle) { |
178 | 124 | if (timerHandle < 0) { |
179 | 125 | throw jsi::JSError(runtime, "clearTimeout called with an invalid handle"); |
|
0 commit comments