mirror of
https://github.com/esphome/esphome.git
synced 2025-10-05 11:23:47 +01:00
ble pool
This commit is contained in:
@@ -12,11 +12,11 @@ namespace esp32_ble {
|
||||
|
||||
// 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
|
||||
template<size_t SIZE> class BLEEventPool {
|
||||
template<uint8_t SIZE> class BLEEventPool {
|
||||
public:
|
||||
BLEEventPool() {
|
||||
// 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;
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ template<size_t SIZE> class BLEEventPool {
|
||||
|
||||
~BLEEventPool() {
|
||||
// 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) {
|
||||
delete this->events_[i];
|
||||
}
|
||||
|
@@ -10,7 +10,7 @@ namespace esp32_ble {
|
||||
|
||||
// Lock-free SPSC queue that stores indices instead of pointers
|
||||
// This allows us to use a pre-allocated pool of objects
|
||||
template<size_t SIZE> class LockFreeIndexQueue {
|
||||
template<uint8_t SIZE> class LockFreeIndexQueue {
|
||||
public:
|
||||
static constexpr uint8_t INVALID_INDEX = 0xFF; // 255, which is > MAX_BLE_QUEUE_SIZE (64)
|
||||
|
||||
|
Reference in New Issue
Block a user