mirror of
https://github.com/esphome/esphome.git
synced 2025-09-18 03:02:20 +01:00
ble pool
This commit is contained in:
@@ -219,7 +219,7 @@ class BLEEvent {
|
||||
return; // Invalid event, but we can't log in header file
|
||||
}
|
||||
|
||||
// Heap-allocate param
|
||||
// Heap-allocate param and data
|
||||
// Heap allocation is used because GATTC/GATTS events are rare (<1% of events)
|
||||
// while GAP events (99%) are stored inline to minimize memory usage
|
||||
this->event_.gattc.gattc_param = new esp_ble_gattc_cb_param_t(*p);
|
||||
@@ -252,7 +252,7 @@ class BLEEvent {
|
||||
return; // Invalid event, but we can't log in header file
|
||||
}
|
||||
|
||||
// Heap-allocate param
|
||||
// Heap-allocate param and data
|
||||
// Heap allocation is used because GATTC/GATTS events are rare (<1% of events)
|
||||
// while GAP events (99%) are stored inline to minimize memory usage
|
||||
this->event_.gatts.gatts_param = new esp_ble_gatts_cb_param_t(*p);
|
||||
|
@@ -71,8 +71,11 @@ template<class T, uint8_t SIZE> class LockFreeQueue {
|
||||
|
||||
protected:
|
||||
T *buffer_[SIZE];
|
||||
// Atomic: written by consumer (pop), read by producer (push) to check if full
|
||||
std::atomic<uint8_t> head_;
|
||||
// Atomic: written by producer (push), read by consumer (pop) to check if empty
|
||||
std::atomic<uint8_t> tail_;
|
||||
// Atomic: written by producer (push/increment), read+reset by consumer (get_and_reset)
|
||||
std::atomic<uint32_t> dropped_count_; // Keep this larger for accumulated counts
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user