mirror of
https://github.com/esphome/esphome.git
synced 2025-09-15 09:42:19 +01:00
comments
This commit is contained in:
@@ -46,7 +46,13 @@ template<class T> class Queue {
|
||||
}
|
||||
|
||||
size_t size() const {
|
||||
return q_.size(); // Atomic read, no lock needed
|
||||
// Lock-free size check. While std::queue::size() is not thread-safe, we intentionally
|
||||
// avoid locking here to prevent blocking the BLE callback thread. The size is only
|
||||
// used to decide whether to drop incoming events when the queue is near capacity.
|
||||
// With a queue limit of 40-64 events and normal processing, dropping events should
|
||||
// be extremely rare. When it does approach capacity, being off by 1-2 events is
|
||||
// acceptable to avoid blocking the BLE stack's time-sensitive callbacks.
|
||||
return q_.size();
|
||||
}
|
||||
|
||||
protected:
|
||||
|
Reference in New Issue
Block a user