Skip to content

Commit d8066c7

Browse files
committed
[chargepoint] Use worker thread pool when timer callbacks needs to send messages => allow no to block the timer thread
1 parent 7289a97 commit d8066c7

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/chargepoint/reservation/ReservationManager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ void ReservationManager::checkExpiries()
311311
if ((connector->status == ChargePointStatus::Reserved) && (connector->reservation_expiry_date <= now))
312312
{
313313
// End reservation
314-
endReservation(connector->id, false);
314+
m_worker_pool.run<void>(std::bind(&ReservationManager::endReservation, this, connector->id, false));
315315
}
316316
}
317317
}

src/chargepoint/status/StatusManager.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ StatusManager::StatusManager(const ocpp::config::IChargePointConfig& sta
6767
m_boot_notification_timer(timer_pool, "Boot notification"),
6868
m_heartbeat_timer(timer_pool, "Heartbeat")
6969
{
70-
m_boot_notification_timer.setCallback(std::bind(&StatusManager::bootNotificationProcess, this));
71-
m_heartbeat_timer.setCallback(std::bind(&StatusManager::heartBeatProcess, this));
70+
m_boot_notification_timer.setCallback([this] { m_worker_pool.run<void>(std::bind(&StatusManager::bootNotificationProcess, this)); });
71+
m_heartbeat_timer.setCallback([this] { m_worker_pool.run<void>(std::bind(&StatusManager::heartBeatProcess, this)); });
7272

7373
trigger_manager.registerHandler(ocpp::types::MessageTrigger::BootNotification, *this);
7474
trigger_manager.registerHandler(ocpp::types::MessageTrigger::Heartbeat, *this);
@@ -178,7 +178,9 @@ bool StatusManager::updateConnectorStatus(unsigned int conn
178178
connector->status_timer.stop();
179179
if (connector->status != connector->last_notified_status)
180180
{
181-
connector->status_timer.setCallback([connector_id, this] { statusNotificationProcess(connector_id); });
181+
connector->status_timer.setCallback(
182+
[this, connector_id]
183+
{ m_worker_pool.run<void>(std::bind(&StatusManager::statusNotificationProcess, this, connector_id)); });
182184
connector->status_timer.start(std::chrono::milliseconds(duration), true);
183185
}
184186
}

0 commit comments

Comments
 (0)