mirror of
https://github.com/esp8266/Arduino.git
synced 2025-07-07 06:01:35 +03:00
scheduled functions: calls from yield are now optional (#6158)
* scheduled functions: calls from yield are now optional * add move constructors * yield every 100ms
This commit is contained in:
@ -26,21 +26,33 @@
|
||||
|
||||
#define SCHEDULED_FN_MAX_COUNT 32
|
||||
|
||||
enum schedule_e
|
||||
{
|
||||
SCHEDULED_FUNCTION_ONCE_PER_LOOP,
|
||||
SCHEDULED_FUNCTION_WITHOUT_YIELDELAYCALLS
|
||||
};
|
||||
|
||||
// * Run the lambda only once next time
|
||||
//bool schedule_function(std::function<void(void)>&& fn);
|
||||
bool schedule_function(const std::function<void(void)>& fn);
|
||||
bool schedule_function(std::function<void(void)>&& fn,
|
||||
schedule_e policy = SCHEDULED_FUNCTION_ONCE_PER_LOOP);
|
||||
bool schedule_function(const std::function<void(void)>& fn,
|
||||
schedule_e policy = SCHEDULED_FUNCTION_ONCE_PER_LOOP);
|
||||
|
||||
// * Run the lambda 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);
|
||||
bool schedule_function_us(const std::function<bool(void)>& fn, uint32_t repeat_us);
|
||||
bool schedule_function_us(std::function<bool(void)>&& fn,
|
||||
uint32_t repeat_us,
|
||||
schedule_e policy = SCHEDULED_FUNCTION_ONCE_PER_LOOP);
|
||||
bool schedule_function_us(const std::function<bool(void)>& fn,
|
||||
uint32_t repeat_us,
|
||||
schedule_e policy = SCHEDULED_FUNCTION_ONCE_PER_LOOP);
|
||||
|
||||
// Run all scheduled functions.
|
||||
// Use this function if your are not using `loop`, or `loop` does not return
|
||||
// on a regular basis.
|
||||
void run_scheduled_functions();
|
||||
void run_scheduled_functions(schedule_e policy = SCHEDULED_FUNCTION_ONCE_PER_LOOP);
|
||||
|
||||
#endif //ESP_SCHEDULE_H
|
||||
|
Reference in New Issue
Block a user