@geastack/host 0.1.19 → 0.1.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/host/timers.cpp +19 -4
- package/package.json +1 -1
package/host/timers.cpp
CHANGED
|
@@ -88,9 +88,15 @@ struct ScheduledTimer {
|
|
|
88
88
|
|
|
89
89
|
class TimerScheduler {
|
|
90
90
|
public:
|
|
91
|
+
// Function-local statics are read through an acquire-loaded pointer: on
|
|
92
|
+
// targets without hardware atomics (ESP32-S3) each guarded access takes an
|
|
93
|
+
// RTOS mutex, and these run on every frame.
|
|
91
94
|
static TimerScheduler &instance()
|
|
92
95
|
{
|
|
96
|
+
static std::atomic<TimerScheduler *> ready{nullptr};
|
|
97
|
+
if (auto *scheduler = ready.load(std::memory_order_acquire)) return *scheduler;
|
|
93
98
|
static TimerScheduler scheduler;
|
|
99
|
+
ready.store(&scheduler, std::memory_order_release);
|
|
94
100
|
return scheduler;
|
|
95
101
|
}
|
|
96
102
|
|
|
@@ -197,7 +203,11 @@ class AnimationFrameQueue {
|
|
|
197
203
|
public:
|
|
198
204
|
static AnimationFrameQueue &instance()
|
|
199
205
|
{
|
|
206
|
+
// See TimerScheduler::instance().
|
|
207
|
+
static std::atomic<AnimationFrameQueue *> ready{nullptr};
|
|
208
|
+
if (auto *queue = ready.load(std::memory_order_acquire)) return *queue;
|
|
200
209
|
static AnimationFrameQueue queue;
|
|
210
|
+
ready.store(&queue, std::memory_order_release);
|
|
201
211
|
return queue;
|
|
202
212
|
}
|
|
203
213
|
|
|
@@ -279,11 +289,16 @@ private:
|
|
|
279
289
|
// call sites on this so the strings are only built when logging is actually on.
|
|
280
290
|
static bool debugLoggingEnabled()
|
|
281
291
|
{
|
|
282
|
-
|
|
292
|
+
// Constant-initialized, so no guard: -1 until the first read. Racing
|
|
293
|
+
// first reads compute the same value.
|
|
294
|
+
static std::atomic<signed char> enabled{-1};
|
|
295
|
+
signed char value = enabled.load(std::memory_order_relaxed);
|
|
296
|
+
if (value < 0) {
|
|
283
297
|
const char *p = std::getenv("GEA_RAF_DEBUG_LOG");
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
298
|
+
value = p && p[0] != '\0' ? 1 : 0;
|
|
299
|
+
enabled.store(value, std::memory_order_relaxed);
|
|
300
|
+
}
|
|
301
|
+
return value != 0;
|
|
287
302
|
}
|
|
288
303
|
|
|
289
304
|
void logDebug(const std::string &message)
|