diff options
author | Sven Gothel <[email protected]> | 2020-06-24 22:55:16 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2020-06-24 22:55:16 +0200 |
commit | 9764a6b07cfa55ee39a41a02d3ac1577736b0124 (patch) | |
tree | 6249e9f23ea24a88e31baf3d8cbf75d05112e4e5 | |
parent | 3cf7e59c2dbd20e1e781d90d9308a56fd449e040 (diff) |
HCIHandler::reader: If ringbuffer full, drop capacity/2 oldest elements
This to scale a bit better, assuming old entries are unrelated anyways.
-rw-r--r-- | src/direct_bt/HCIHandler.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/direct_bt/HCIHandler.cpp b/src/direct_bt/HCIHandler.cpp index cbe38a9f..1d4c1a64 100644 --- a/src/direct_bt/HCIHandler.cpp +++ b/src/direct_bt/HCIHandler.cpp @@ -188,9 +188,9 @@ void HCIHandler::hciReaderThreadImpl() { if( event->isEvent(HCIEventType::CMD_STATUS) || event->isEvent(HCIEventType::CMD_COMPLETE) ) { if( hciEventRing.isFull() ) { - std::shared_ptr<HCIEvent> ev = hciEventRing.get(); - INFO_PRINT("HCIHandler::reader: Drop (oldest, ring full) %s", - ( nullptr != ev ) ? ev->toString().c_str() : "nil"); + const int dropCount = hciEventRing.capacity()/2; + hciEventRing.drop(dropCount); + INFO_PRINT("HCIHandler::reader: Drop (%d oldest elements of %d capacity, ring full)", dropCount, hciEventRing.capacity()); } DBG_PRINT("HCIHandler::reader: CmdResult %s", event->toString().c_str()); hciEventRing.putBlocking( event ); |