1
0
Fork 0
mirror of https://github.com/Atmosphere-NX/Atmosphere.git synced 2025-01-09 19:06:36 +00:00

Do the same for ILimitedResource; fix handle table def, for the moment

This commit is contained in:
TuxSH 2018-11-06 00:16:33 +01:00 committed by Michael Scire
parent ac6762bb6c
commit 4a1021f220
6 changed files with 13 additions and 6 deletions

View file

@ -4,6 +4,8 @@
#include <mesosphere/core/KAutoObject.hpp>
#include <tuple>
#define MESOSPHERE_LIMITED_RESOURCE_TRAITS(maxTime) static constexpr auto maxResourceAcqWaitTime = maxTime;
namespace mesosphere
{
@ -15,12 +17,10 @@ void ReleaseResource(const SharedPtr<KResourceLimit> &reslimit, KAutoObject::Typ
}
template<typename Derived, uint maxResourceAcqWaitTimeMsec = 1000u>
template<typename Derived>
class ILimitedResource {
public:
static constexpr auto maxResourceAcqWaitTime = maxResourceAcqWaitTimeMsec * 1ms;
const SharedPtr<KProcess>& GetResourceOwner() const { return resourceOwner; }
void SetResourceOwner(SharedPtr<KProcess> owner)
{

View file

@ -22,6 +22,7 @@ class KEvent final :
public:
MESOSPHERE_AUTO_OBJECT_TRAITS(AutoObject, Event);
MESOSPHERE_CLIENT_SERVER_PARENT_TRAITS(ReadableEvent, WritableEvent);
MESOSPHERE_LIMITED_RESOURCE_TRAITS(1s);
virtual ~KEvent();

View file

@ -2,6 +2,7 @@
#include <mesosphere/core/util.hpp>
#include <mesosphere/core/Handle.hpp>
#include <mesosphere/core/Result.hpp>
#include <mesosphere/core/KAutoObject.hpp>
#include <mesosphere/arch/KSpinLock.hpp>
#include <array>
@ -46,7 +47,8 @@ class KHandleTable final {
constexpr size_t GetSize() const { return size; }
constexpr size_t GetCapacity() const { return capacity; }
KHandleTable(size_t capacity);
Result Initialize(size_t capacity); // TODO: implement!
~KHandleTable();
private:

View file

@ -6,6 +6,7 @@ class KResourceLimit;
#include <mesosphere/core/util.hpp>
#include <mesosphere/core/KAutoObject.hpp>
#include <mesosphere/interfaces/ISetAllocated.hpp>
#include <mesosphere/processes/KHandleTable.hpp>
namespace mesosphere
{
@ -28,6 +29,7 @@ class KProcess : public KAutoObject {
long schedulerOperationCount = -1;
SharedPtr<KResourceLimit> reslimit{};
KHandleTable handleTable{};
};
inline void intrusive_ptr_add_ref(KProcess *obj)

View file

@ -22,7 +22,7 @@ using ThreadMutexWaitListBaseHook = boost::intrusive::list_base_hook<boost::int
class KThread final :
public KAutoObject,
public ILimitedResource<KThread, 100u>,
public ILimitedResource<KThread>,
public ISetAllocated<KThread>,
public IAlarmable,
public ThreadWaitListBaseHook,
@ -31,6 +31,7 @@ class KThread final :
public:
MESOSPHERE_AUTO_OBJECT_TRAITS(AutoObject, Thread);
MESOSPHERE_LIMITED_RESOURCE_TRAITS(100ms);
class StackParameters {
public:

View file

@ -115,6 +115,7 @@ void KHandleTable::Destroy()
}
}
/*
KHandleTable::KHandleTable(size_t capacity_) : capacity((u16)capacity_)
{
// Note: caller should check the > case, and return an error in that case!
@ -123,7 +124,7 @@ KHandleTable::KHandleTable(size_t capacity_) : capacity((u16)capacity_)
u16 capa = capacity;
Destroy();
capacity = capa;
}
}*/
KHandleTable::~KHandleTable()
{