mirror of
https://github.com/esphome/esphome.git
synced 2026-06-24 14:55:05 +00:00
[core] Address review: per-phase scheduler ids, log wording, doc typo
This commit is contained in:
@@ -448,7 +448,7 @@ class Component {
|
||||
* Similar to javascript's setTimeout(). Empty name means no cancelling possible.
|
||||
*
|
||||
* IMPORTANT: Do not rely on this having correct timing. This is only called from
|
||||
* loop() and therefore can be significantly delay. If you need exact timing please
|
||||
* loop() and therefore can be significantly delayed. If you need exact timing please
|
||||
* use hardware timers.
|
||||
*
|
||||
* IMPORTANT: The provided name pointer must remain valid for the lifetime of the scheduler item.
|
||||
|
||||
@@ -156,6 +156,7 @@ script:
|
||||
|
||||
// Simulate a burst of defer operations like ratgdo does with state updates
|
||||
// These should execute immediately and recycle quickly to the pool
|
||||
// Phase-specific id range (0..9) so ids never collide with later phases
|
||||
for (int i = 0; i < 10; i++) {
|
||||
App.scheduler.set_timeout(component, static_cast<uint32_t>(i), 0, [i]() {
|
||||
ESP_LOGD("test", "Defer %d executed", i);
|
||||
@@ -206,8 +207,9 @@ script:
|
||||
// Now create 8 new timeouts - they should reuse from pool when available
|
||||
int reuse_test_count = 8;
|
||||
|
||||
// Phase-specific id range (100..107) so ids never collide with other phases
|
||||
for (int i = 0; i < reuse_test_count; i++) {
|
||||
App.scheduler.set_timeout(component, static_cast<uint32_t>(i), 10 + i * 5, [i]() {
|
||||
App.scheduler.set_timeout(component, static_cast<uint32_t>(100 + i), 10 + i * 5, [i]() {
|
||||
ESP_LOGD("test", "Reuse test %d completed", i);
|
||||
});
|
||||
}
|
||||
@@ -227,8 +229,9 @@ script:
|
||||
auto *component = id(test_sensor);
|
||||
int full_reuse_count = 10;
|
||||
|
||||
// Phase-specific id range (200..209) so ids never collide with other phases
|
||||
for (int i = 0; i < full_reuse_count; i++) {
|
||||
App.scheduler.set_timeout(component, static_cast<uint32_t>(i), 10 + i * 5, [i]() {
|
||||
App.scheduler.set_timeout(component, static_cast<uint32_t>(200 + i), 10 + i * 5, [i]() {
|
||||
ESP_LOGD("test", "Full reuse test %d completed", i);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -129,7 +129,7 @@ script:
|
||||
});
|
||||
static const char CANCEL_NAME_2[] = "cancel_test";
|
||||
App.scheduler.cancel_timeout(component2, CANCEL_NAME_2);
|
||||
ESP_LOGI("test", "Cancelled timeout using different string object");
|
||||
ESP_LOGI("test", "Cancelled timeout using different buffer with same content");
|
||||
|
||||
// Test 11: const char* name with defer
|
||||
class TestDynamicDeferComponent : public Component {
|
||||
|
||||
@@ -99,7 +99,7 @@ async def test_scheduler_string_test(
|
||||
timeout_count += 1
|
||||
|
||||
# Check for cancel test
|
||||
elif "Cancelled timeout using different string object" in clean_line:
|
||||
elif "Cancelled timeout using different buffer with same content" in clean_line:
|
||||
cancel_test_done.set()
|
||||
|
||||
# Check for final results
|
||||
|
||||
Reference in New Issue
Block a user