1
0
mirror of https://github.com/esphome/esphome.git synced 2025-10-05 03:13:49 +01:00
This commit is contained in:
J. Nick Koston
2025-06-16 14:55:15 +02:00
parent 419e4e63e9
commit 3d18495270
2 changed files with 4 additions and 4 deletions

View File

@@ -12,11 +12,11 @@ namespace esp32_ble {
// BLE Event Pool - On-demand pool of BLEEvent objects to avoid heap fragmentation // BLE Event Pool - On-demand pool of BLEEvent objects to avoid heap fragmentation
// Events are allocated on first use and reused thereafter, growing to peak usage // Events are allocated on first use and reused thereafter, growing to peak usage
template<size_t SIZE> class BLEEventPool { template<uint8_t SIZE> class BLEEventPool {
public: public:
BLEEventPool() { BLEEventPool() {
// Initialize all slots as unallocated // Initialize all slots as unallocated
for (size_t i = 0; i < SIZE; i++) { for (uint8_t i = 0; i < SIZE; i++) {
this->events_[i] = nullptr; this->events_[i] = nullptr;
} }
@@ -33,7 +33,7 @@ template<size_t SIZE> class BLEEventPool {
~BLEEventPool() { ~BLEEventPool() {
// Delete any events that were created // Delete any events that were created
for (size_t i = 0; i < SIZE; i++) { for (uint8_t i = 0; i < SIZE; i++) {
if (this->events_[i] != nullptr) { if (this->events_[i] != nullptr) {
delete this->events_[i]; delete this->events_[i];
} }

View File

@@ -10,7 +10,7 @@ namespace esp32_ble {
// Lock-free SPSC queue that stores indices instead of pointers // Lock-free SPSC queue that stores indices instead of pointers
// This allows us to use a pre-allocated pool of objects // This allows us to use a pre-allocated pool of objects
template<size_t SIZE> class LockFreeIndexQueue { template<uint8_t SIZE> class LockFreeIndexQueue {
public: public:
static constexpr uint8_t INVALID_INDEX = 0xFF; // 255, which is > MAX_BLE_QUEUE_SIZE (64) static constexpr uint8_t INVALID_INDEX = 0xFF; // 255, which is > MAX_BLE_QUEUE_SIZE (64)