1
0
mirror of https://github.com/esphome/esphome.git synced 2025-10-05 19:33:47 +01:00
This commit is contained in:
J. Nick Koston
2025-06-16 15:16:15 +02:00
parent e7e4b995bf
commit 104658e43a

View File

@@ -30,8 +30,9 @@ template<uint8_t SIZE> class BLEEventPool {
BLEEvent *allocate() {
// Try to get from free list first
BLEEvent *event = this->free_list_.pop();
if (event != nullptr)
return event;
if (event == nullptr) {
// Need to create a new event
if (this->total_created_ >= SIZE) {
// Pool is at capacity
@@ -50,8 +51,6 @@ template<uint8_t SIZE> class BLEEventPool {
// Placement new to construct the object
new (event) BLEEvent();
this->total_created_.fetch_add(1, std::memory_order_relaxed);
}
return event;
}