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

recurrent scheduled functions max delay update#8949

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
dok-net wants to merge29 commits intoesp8266:master
base:master
Choose a base branch
Loading
fromdok-net:fix_8947
Draft
Show file tree
Hide file tree
Changes from1 commit
Commits
Show all changes
29 commits
Select commitHold shift + click to select a range
2757aa2
Revert `compute_scheduled_recurrent_grain`
dok-netJul 1, 2023
a81e544
wip
dok-netJul 1, 2023
588e153
Add function to retrieve the time remaining until the (next) timeout …
dok-netNov 26, 2019
a435fa5
Rename and reformat according to review.
dok-netNov 27, 2019
232961e
Revert _current as member change.
dok-netNov 27, 2019
210c3d4
Fix expiredOneShot to properly stay expired forever unless reset.
dok-netNov 27, 2019
a6456d0
Fix "reverse notation return statement"
dok-netNov 27, 2019
9863f71
Reset() was wrecked by resetting _timeout. Reverted.
dok-netNov 27, 2019
9c83f9a
Expired check ALWAYS executes yield policy BEFORE checking expiration…
dok-netDec 2, 2019
4cbe06b
Reformat
dok-netDec 3, 2019
20e6378
Fix comment, remove redundant parentheses
dok-netDec 4, 2019
b0eb345
expired() is not const qualified in PolledTmeout.
dok-netMar 15, 2021
a3612dd
expiredOneShot() qualifed as const, despite asymmetry with expired() …
dok-netMar 16, 2021
c88af7b
Remove alwaysExpired, it is identical to 0 and obfuscates the code.
dok-netApr 5, 2021
4eab7e4
Somewhat easier on the human reader.
dok-netApr 5, 2021
b5285c3
Avoid possible unnecessary time conversion.
dok-netApr 5, 2021
b54576f
Fix one-shot mode in resetToNeverExpires(). Add convenient stop() syn…
dok-netApr 5, 2021
100d2c4
Due to review and discussion, _oneShotExpired removed again.
dok-netApr 5, 2021
81b90c9
Revert removal of PolledTimeout::alwaysExpired
dok-netJul 1, 2023
eaf05e9
Finalize scheduled recurrent function delay logic.
dok-netJul 1, 2023
a09726d
Fix millis/micros mismatch.
dok-netJul 1, 2023
4d3655b
ISR safety.
dok-netJul 1, 2023
55d465a
Returning max delay value that is uint-wrap around safe.
dok-netJul 2, 2023
c41a2c2
Add pseudo-get delay function for scheduled functions
dok-netJul 2, 2023
4e654d1
Worked out input from PR review.
dok-netJul 20, 2023
717f4ad
use single constexpr definition instead of repeated expression.
dok-netJul 27, 2023
538025a
Simplified roll-over logic
dok-netJul 30, 2023
861cf02
Add rationale for HALF_MAX_MICROS
dok-netJul 30, 2023
b3b4aa0
Use CAS to minimize critical sections.
dok-netSep 6, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PrevPrevious commit
NextNext commit
Fix millis/micros mismatch.
  • Loading branch information
@dok-net
dok-net committedJan 5, 2024
commita09726d672a7cfbb0ceb7006c84a884eaa0a03f2
14 changes: 7 additions & 7 deletionscores/esp8266/Schedule.cpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -120,10 +120,10 @@ bool schedule_recurrent_function_us(const std::function<bool(void)>& fn,
item->alarm = alarm;

// prevent new item overwriting an already expired rTarget.
const int32_t rRemaining = rTarget -millis();
const int32_t rRemaining = rTarget -micros();
if (!rFirst || (rRemaining > 0 && static_cast<uint32_t>(rRemaining) > item->callNow.remaining()))
{
rTarget =millis() + item->callNow.remaining();
rTarget =micros() + item->callNow.remaining();
}

esp8266::InterruptLock lockAllInterruptsInThisScope;
Expand All@@ -141,11 +141,11 @@ bool schedule_recurrent_function_us(const std::function<bool(void)>& fn,
return true;
}

uint32_tget_scheduled_recurrent_delay()
uint32_tget_scheduled_recurrent_delay_us()
{
if (!rFirst) return ~static_cast<uint32_t>(0);
// handle already expired rTarget.
const int32_t rRemaining = rTarget -millis();
const int32_t rRemaining = rTarget -micros();
return (rRemaining > 0) ? static_cast<uint32_t>(rRemaining) : 0;
}

Expand DownExpand Up@@ -209,7 +209,7 @@ void run_scheduled_recurrent_functions()
fence = true;
}

rTarget =millis() + current->callNow.remaining();
rTarget =micros() + current->callNow.remaining();
recurrent_fn_t* prev = nullptr;
// prevent scheduling of new functions during this run
auto stop = rLast;
Expand DownExpand Up@@ -249,10 +249,10 @@ void run_scheduled_recurrent_functions()
prev = current;
current = current->mNext;
// prevent current item overwriting an already expired rTarget.
const int32_t rRemaining = rTarget -millis();
const int32_t rRemaining = rTarget -micros();
if (rRemaining > 0 && static_cast<uint32_t>(rRemaining) > current->callNow.remaining())
{
rTarget =millis() + current->callNow.remaining();
rTarget =micros() + current->callNow.remaining();
}
}

Expand Down
4 changes: 2 additions & 2 deletionscores/esp8266/Schedule.h
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -39,10 +39,10 @@
// scheduled function happen more often: every yield() (vs every loop()),
// and time resolution is microsecond (vs millisecond). Details are below.

//get_scheduled_recurrent_delay() is used by delay() to give a chance to
//get_scheduled_recurrent_delay_us() is used by delay() to give a chance to
// all recurrent functions to run per their timing requirement.

uint32_tget_scheduled_recurrent_delay();
uint32_tget_scheduled_recurrent_delay_us();

// scheduled functions called once:
//
Expand Down
2 changes: 1 addition & 1 deletioncores/esp8266/core_esp8266_main.cpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -174,7 +174,7 @@ bool esp_try_delay(const uint32_t start_ms, const uint32_t timeout_ms, const uin
}

// compute greatest delay interval with respect to scheduled recurrent functions
const uint32_t max_delay_ms = std::min(intvl_ms,get_scheduled_recurrent_delay());
const uint32_t max_delay_ms = std::min(intvl_ms,get_scheduled_recurrent_delay_us() / 1000);

// recurrent scheduled functions will be called from esp_delay()->esp_suspend()
esp_delay(std::min((timeout_ms - expired), max_delay_ms));
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp