Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit4b85b05

Browse files
committed
Add rationale for HALF_MAX_MICROS
1 parent8518563 commit4b85b05

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

‎cores/esp8266/Schedule.cpp‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,16 @@ static recurrent_fn_t* rLast = nullptr;
4949
// The target time for scheduling the next timed recurrent function
5050
staticdecltype(micros()) rTarget;
5151

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.
5262
constexprdecltype(micros()) HALF_MAX_MICROS = ~static_cast<decltype(micros())>(0) >> 1;
5363

5464
// Returns a pointer to an unused sched_fn_t,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp