[wireguard] Replace std::bind with inline lambdas

Replace std::bind calls with [this] lambdas for add_on_time_sync_callback
and defer registrations. The [this] lambda fits within the Callback
inline storage threshold (sizeof(void*)), avoiding heap allocations.
This commit is contained in:
J. Nick Koston
2026-03-19 00:07:07 -10:00
parent 403ba262c6
commit 64b50a5cb6
+3 -3
View File
@@ -48,8 +48,8 @@ void Wireguard::setup() {
if (this->wg_initialized_ == ESP_OK) {
ESP_LOGI(TAG, "Initialized");
this->wg_peer_offline_time_ = millis();
this->srctime_->add_on_time_sync_callback(std::bind(&Wireguard::start_connection_, this));
this->defer(std::bind(&Wireguard::start_connection_, this)); // defer to avoid blocking setup
this->srctime_->add_on_time_sync_callback([this]() { this->start_connection_(); });
this->defer([this]() { this->start_connection_(); }); // defer to avoid blocking setup
#ifdef USE_TEXT_SENSOR
if (this->address_sensor_ != nullptr) {
@@ -206,7 +206,7 @@ void Wireguard::enable() {
void Wireguard::disable() {
this->enabled_ = false;
this->defer(std::bind(&Wireguard::stop_connection_, this)); // defer to avoid blocking running loop
this->defer([this]() { this->stop_connection_(); }); // defer to avoid blocking running loop
ESP_LOGI(TAG, "Disabled");
this->publish_enabled_state();
}