From 4b28e4626e744ac9b779a680f8e9647014956dda Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Sun, 26 Jul 2026 21:46:37 +0200 Subject: kapi/devices: implement locking discipline --- kapi/kapi/devices/bus.hpp | 3 +++ kapi/kapi/devices/device_registry.hpp | 3 +++ kapi/kapi/devices/facet_registry.hpp | 3 +++ 3 files changed, 9 insertions(+) (limited to 'kapi') diff --git a/kapi/kapi/devices/bus.hpp b/kapi/kapi/devices/bus.hpp index 13951e46..2ee12628 100644 --- a/kapi/kapi/devices/bus.hpp +++ b/kapi/kapi/devices/bus.hpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include @@ -65,6 +66,8 @@ namespace kapi::devices private: auto do_remove_child(device & child) -> void; + mutable tracked_mutex m_lock{}; + bus_protocol * m_protocol{}; kstd::vector> m_devices{}; }; diff --git a/kapi/kapi/devices/device_registry.hpp b/kapi/kapi/devices/device_registry.hpp index a65bd4ad..816ad984 100644 --- a/kapi/kapi/devices/device_registry.hpp +++ b/kapi/kapi/devices/device_registry.hpp @@ -4,6 +4,7 @@ // IWYU pragma: private, include #include +#include #include #include @@ -79,6 +80,8 @@ namespace kapi::devices auto subscribe(kstd::weak_ptr observer) -> void; private: + mutable tracked_mutex m_lock{}; + kstd::flat_map> m_devices{}; kstd::vector> m_observers{}; }; diff --git a/kapi/kapi/devices/facet_registry.hpp b/kapi/kapi/devices/facet_registry.hpp index 82bb304b..7006c026 100644 --- a/kapi/kapi/devices/facet_registry.hpp +++ b/kapi/kapi/devices/facet_registry.hpp @@ -5,6 +5,7 @@ #include #include +#include #include #include @@ -268,6 +269,8 @@ namespace kapi::devices //! @param device The device. auto do_notify_withdrawn(kapi::capabilities::facet_id id, device const & device) -> void; + mutable tracked_mutex m_lock{}; + kstd::vector m_entries; kstd::vector> m_observers; kstd::vector m_static_observers; -- cgit v1.2.3