File tree 1 file changed +10
-0
lines changed
1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -49,6 +49,16 @@ static recurrent_fn_t* rLast = nullptr;
49
49
// The target time for scheduling the next timed recurrent function
50
50
static decltype (micros()) rTarget;
51
51
52
+ // As 32 bit unsigned integer, micros() rolls over every 71.6 minutes.
53
+ // For unambiguous earlier/later order between two timestamps,
54
+ // despite roll over, there is a limit on the maximum duration
55
+ // that can be requested, if full expiration must be observable:
56
+ // later - earlier >= 0 for both later >= earlier or (rolled over) later <= earlier
57
+ // Also, expiration should remain observable for a useful duration of time:
58
+ // now - (start + period) >= 0 for now - start >= 0 despite (start + period) >= now
59
+ // A well-balanced solution, not breaking on two's compliment signed arithmetic,
60
+ // is limiting durations to the maximum signed value of the same word size
61
+ // as the original unsigned word.
52
62
constexpr decltype (micros()) HALF_MAX_MICROS = ~static_cast<decltype(micros())>(0 ) >> 1;
53
63
54
64
// Returns a pointer to an unused sched_fn_t,
You can’t perform that action at this time.
0 commit comments