From 6642373795cd78f3db562a1b8472ff3c0778c45e Mon Sep 17 00:00:00 2001 From: TuxSH Date: Mon, 19 Nov 2018 11:19:25 +0100 Subject: [PATCH] meso: add FindObject to KObjectAllocator * --- .../mesosphere/kresources/KObjectAllocator.hpp | 16 ++++++++++++++++ .../include/mesosphere/processes/KEvent.hpp | 1 - .../mesosphere/processes/KWritableEvent.hpp | 1 - 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/mesosphere/include/mesosphere/kresources/KObjectAllocator.hpp b/mesosphere/include/mesosphere/kresources/KObjectAllocator.hpp index 906d0e4c5..a26faef7b 100644 --- a/mesosphere/include/mesosphere/kresources/KObjectAllocator.hpp +++ b/mesosphere/include/mesosphere/kresources/KObjectAllocator.hpp @@ -1,6 +1,7 @@ #pragma once #include #include +#include #include #include @@ -17,6 +18,14 @@ class KObjectAllocator { } }; + + struct ComparatorEqual { + constexpr u64 operator()(const T &val) const + { + return val.GetComparisonKey(); + } + }; + public: struct HookTag; @@ -29,6 +38,7 @@ class KObjectAllocator { T, boost::intrusive::base_hook, boost::intrusive::compare + //boost::intrusive::key_of_value >::type; using pointer = T *; @@ -61,6 +71,12 @@ class KObjectAllocator { allocatedSet.erase(obj); } + T *FindObject(u64 comparisonKey) + { + auto it = allocatedSet.find(comparisonKey, ComparatorEqual{}); + return it != allocatedSet.end() ? &*it : nullptr; + } + private: AllocatedSetType allocatedSet{}; KSlabHeap slabHeap{}; diff --git a/mesosphere/include/mesosphere/processes/KEvent.hpp b/mesosphere/include/mesosphere/processes/KEvent.hpp index 3559710a9..16891c1b5 100644 --- a/mesosphere/include/mesosphere/processes/KEvent.hpp +++ b/mesosphere/include/mesosphere/processes/KEvent.hpp @@ -2,7 +2,6 @@ #include #include -#include #include #include #include diff --git a/mesosphere/include/mesosphere/processes/KWritableEvent.hpp b/mesosphere/include/mesosphere/processes/KWritableEvent.hpp index e57d79c77..a2e0ad2f4 100644 --- a/mesosphere/include/mesosphere/processes/KWritableEvent.hpp +++ b/mesosphere/include/mesosphere/processes/KWritableEvent.hpp @@ -2,7 +2,6 @@ #include #include -#include #include #include