Merge branch 'defer_const' into integration

This commit is contained in:
J. Nick Koston 2025-07-04 20:33:07 -05:00
commit 303a8ff87a
No known key found for this signature in database
3 changed files with 19 additions and 1 deletions

View File

@ -248,6 +248,9 @@ bool Component::cancel_defer(const std::string &name) { // NOLINT
void Component::defer(const std::string &name, std::function<void()> &&f) { // NOLINT
App.scheduler.set_timeout(this, name, 0, std::move(f));
}
void Component::defer(const char *name, std::function<void()> &&f) { // NOLINT
App.scheduler.set_timeout(this, name, 0, std::move(f));
}
void Component::set_timeout(uint32_t timeout, std::function<void()> &&f) { // NOLINT
App.scheduler.set_timeout(this, "", timeout, std::move(f));
}

View File

@ -381,6 +381,21 @@ class Component {
*/
void defer(const std::string &name, std::function<void()> &&f); // NOLINT
/** Defer a callback to the next loop() call with a const char* name.
*
* IMPORTANT: The provided name pointer must remain valid for the lifetime of the deferred task.
* This means the name should be:
* - A string literal (e.g., "update")
* - A static const char* variable
* - A pointer with lifetime >= the deferred execution
*
* For dynamic strings, use the std::string overload instead.
*
* @param name The name of the defer function (must have static lifetime)
* @param f The callback
*/
void defer(const char *name, std::function<void()> &&f); // NOLINT
/// Defer a callback to the next loop() call.
void defer(std::function<void()> &&f); // NOLINT

View File

@ -15,7 +15,7 @@ click==8.1.7
esphome-dashboard==20250514.0
aioesphomeapi==34.1.0
zeroconf==0.147.0
puremagic==1.29
puremagic==1.30
ruamel.yaml==0.18.14 # dashboard_import
esphome-glyphsets==0.2.0
pillow==10.4.0