mirror of
https://github.com/Atmosphere-NX/Atmosphere
synced 2025-01-03 19:14:44 +00:00
meso: add FindObject to KObjectAllocator *
This commit is contained in:
parent
1a924ad317
commit
6642373795
3 changed files with 16 additions and 2 deletions
|
@ -1,6 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <boost/intrusive/set.hpp>
|
#include <boost/intrusive/set.hpp>
|
||||||
#include <mesosphere/core/util.hpp>
|
#include <mesosphere/core/util.hpp>
|
||||||
|
#include <mesosphere/core/KAutoObject.hpp>
|
||||||
#include <mesosphere/kresources/KSlabHeap.hpp>
|
#include <mesosphere/kresources/KSlabHeap.hpp>
|
||||||
#include <mesosphere/threading/KMutex.hpp>
|
#include <mesosphere/threading/KMutex.hpp>
|
||||||
|
|
||||||
|
@ -17,6 +18,14 @@ class KObjectAllocator {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
struct ComparatorEqual {
|
||||||
|
constexpr u64 operator()(const T &val) const
|
||||||
|
{
|
||||||
|
return val.GetComparisonKey();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
struct HookTag;
|
struct HookTag;
|
||||||
|
|
||||||
|
@ -29,6 +38,7 @@ class KObjectAllocator {
|
||||||
T,
|
T,
|
||||||
boost::intrusive::base_hook<AllocatedSetHookType>,
|
boost::intrusive::base_hook<AllocatedSetHookType>,
|
||||||
boost::intrusive::compare<Comparator>
|
boost::intrusive::compare<Comparator>
|
||||||
|
//boost::intrusive::key_of_value<KeyOfValue>
|
||||||
>::type;
|
>::type;
|
||||||
|
|
||||||
using pointer = T *;
|
using pointer = T *;
|
||||||
|
@ -61,6 +71,12 @@ class KObjectAllocator {
|
||||||
allocatedSet.erase(obj);
|
allocatedSet.erase(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
T *FindObject(u64 comparisonKey)
|
||||||
|
{
|
||||||
|
auto it = allocatedSet.find(comparisonKey, ComparatorEqual{});
|
||||||
|
return it != allocatedSet.end() ? &*it : nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
AllocatedSetType allocatedSet{};
|
AllocatedSetType allocatedSet{};
|
||||||
KSlabHeap<T> slabHeap{};
|
KSlabHeap<T> slabHeap{};
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
#include <mesosphere/core/util.hpp>
|
#include <mesosphere/core/util.hpp>
|
||||||
#include <mesosphere/core/Result.hpp>
|
#include <mesosphere/core/Result.hpp>
|
||||||
#include <mesosphere/core/KAutoObject.hpp>
|
|
||||||
#include <mesosphere/interfaces/ISetAllocated.hpp>
|
#include <mesosphere/interfaces/ISetAllocated.hpp>
|
||||||
#include <mesosphere/interfaces/ILimitedResource.hpp>
|
#include <mesosphere/interfaces/ILimitedResource.hpp>
|
||||||
#include <mesosphere/interfaces/IClientServerParent.hpp>
|
#include <mesosphere/interfaces/IClientServerParent.hpp>
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
#include <mesosphere/core/util.hpp>
|
#include <mesosphere/core/util.hpp>
|
||||||
#include <mesosphere/core/Result.hpp>
|
#include <mesosphere/core/Result.hpp>
|
||||||
#include <mesosphere/core/KAutoObject.hpp>
|
|
||||||
#include <mesosphere/interfaces/ISetAllocated.hpp>
|
#include <mesosphere/interfaces/ISetAllocated.hpp>
|
||||||
#include <mesosphere/interfaces/IServer.hpp>
|
#include <mesosphere/interfaces/IServer.hpp>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue