Extract elapsedAtLeast to core/util, dedupe the throttle rationale, and correct the alloc-count/PLAN citations

This commit is contained in:
2026-08-03 14:58:33 -04:00
parent 170b2e4994
commit 32c7e959ae
7 changed files with 129 additions and 24 deletions
+5
View File
@@ -5,3 +5,8 @@ reasampler_test(file_bytes LINK file_bytes)
add_library(curve_law INTERFACE)
target_include_directories(curve_law INTERFACE ${REASAMPLER_SRC_DIR})
reasampler_test(curve_law LINK curve_law)
# The GetTickCount()-wraparound-safe throttle-gate test is header-only, hence INTERFACE.
add_library(elapsed_at_least INTERFACE)
target_include_directories(elapsed_at_least INTERFACE ${REASAMPLER_SRC_DIR})
reasampler_test(elapsed_at_least LINK elapsed_at_least)
+19
View File
@@ -0,0 +1,19 @@
#pragma once
// elapsed_at_least — the ONE "has at least this long passed" test behind every
// GetTickCount()-style throttle gate (panel_input's detect cadence, panel_drag's tooltip
// delay). Unsigned subtraction is the deliberate implementation, not an oversight: it is
// exactly correct across a GetTickCount() wraparound (~49.7 days uptime) because `now -
// since`, computed mod 2^32, IS the true forward millisecond distance even when `now`'s
// raw value is numerically less than `since`'s. A signed or `now < since` guard would
// instead wedge the gate shut for up to the wrap period.
namespace reasampler::util {
// True once at least `interval` ms separate `since` from `now` (both GetTickCount()-style
// millisecond counters). `since == 0, interval == 0` reads true, so a zero-initialized
// "last fired" tick opens the gate on its very first call.
inline bool elapsedAtLeast(unsigned int now, unsigned int since, unsigned int interval) {
return now - since >= interval;
}
} // namespace reasampler::util