diff options
author | Sven Gothel <[email protected]> | 2020-10-19 13:40:42 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2020-10-19 13:40:42 +0200 |
commit | 821cb2c742e07afa7d223997e1a3b14615ed65d1 (patch) | |
tree | ac1ef64f58d4789354f97b4c2ee669f76523e619 /api | |
parent | 256ba13b24f9f8ee6559d1d744b43b5e686774b3 (diff) |
DBTManager: Use read lock-free cow_vector for mgmtEventCallbackLists, avoiding locks in callback iteration
Diffstat (limited to 'api')
-rw-r--r-- | api/direct_bt/DBTManager.hpp | 1 | ||||
-rw-r--r-- | api/direct_bt/MgmtTypes.hpp | 5 |
2 files changed, 4 insertions, 2 deletions
diff --git a/api/direct_bt/DBTManager.hpp b/api/direct_bt/DBTManager.hpp index d8bca700..9f8268c5 100644 --- a/api/direct_bt/DBTManager.hpp +++ b/api/direct_bt/DBTManager.hpp @@ -182,7 +182,6 @@ namespace direct_bt { /** One MgmtAdapterEventCallbackList per event type, allowing multiple callbacks to be invoked for each event */ std::array<MgmtAdapterEventCallbackList, static_cast<uint16_t>(MgmtEvent::Opcode::MGMT_EVENT_TYPE_COUNT)> mgmtAdapterEventCallbackLists; - std::recursive_mutex mtx_callbackLists; inline bool isValidMgmtEventCallbackListsIndex(const MgmtEvent::Opcode opc) const noexcept { return static_cast<uint16_t>(opc) < mgmtAdapterEventCallbackLists.size(); } diff --git a/api/direct_bt/MgmtTypes.hpp b/api/direct_bt/MgmtTypes.hpp index 6431f1de..0a7bcedf 100644 --- a/api/direct_bt/MgmtTypes.hpp +++ b/api/direct_bt/MgmtTypes.hpp @@ -1299,6 +1299,9 @@ namespace direct_bt { /** MgmtEventCallback reference */ MgmtEventCallback& getCallback() noexcept { return callback; } + /** const MgmtEventCallback reference */ + const MgmtEventCallback& getCallback() const noexcept { return callback; } + bool operator==(const MgmtAdapterEventCallback& rhs) const noexcept { return dev_id == rhs.dev_id && callback == rhs.callback; } @@ -1310,7 +1313,7 @@ namespace direct_bt { } }; - typedef std::vector<MgmtAdapterEventCallback> MgmtAdapterEventCallbackList; + typedef jau::cow_vector<MgmtAdapterEventCallback> MgmtAdapterEventCallbackList; } // namespace direct_bt |