-
Notifications
You must be signed in to change notification settings - Fork 2
Proposed changes from review #6
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proposed changes from review #6
Conversation
Thanks!
About formatting, I had to change my habits for several reasons:
I'm very sad I couldn't make the Allman PR smoothly indroduced into the core. I'm still thinking of how to achieve it smoothly, maybe file by file if I can make a script that list all modified files in unmerged-yet PRs. |
fa749fc
to
d9c2270
Compare
} | ||
// if no unused items, and count not too high, allocate a new one | ||
else if (sCount < SCHEDULED_FN_MAX_COUNT) | ||
{ | ||
result = new scheduled_fn_t; | ||
++sCount; | ||
} | ||
result->mNext = nullptr; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
otherwise null pointer access if SCHEDULED_FN_MAX_COUNT is exhausted
return result; | ||
} | ||
|
||
static void recycle_fn_unsafe(scheduled_fn_t* fn) | ||
{ | ||
fn->mFunc = mFuncT(); | ||
fn->mFunc = nullptr; // special overload in c++ std lib |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably for performance, so use this style instead of move assignment
@@ -17,11 +17,13 @@ | |||
// Note: there is no mechanism for cancelling scheduled functions. | |||
// Keep that in mind when binding functions to objects which may have short lifetime. | |||
// Returns false if the number of scheduled functions exceeds SCHEDULED_FN_MAX_COUNT. | |||
//bool schedule_function(std::function<void(void)>&& fn); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pending PR esp8266#6129
bool schedule_function(const std::function<void(void)>& fn); | ||
|
||
// Run given function periodically about every <repeat_us> microseconds until it returns false. | ||
// Note that it may be more than <repeat_us> microseconds between calls if `yield` is not called | ||
// frequently, and therefore should not be used for timing critical operations. | ||
//bool schedule_function_us(std::function<bool(void)>&& fn, uint32_t repeat_us); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pending PR esp8266#6129
It's too much to put into words, and giving you source code that compiles should be so much nicer.
What's in it:
sCount < SCHEDULED_FN_MAX_COUNT