mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-01-10 03:16:29 +00:00
Do the same for ILimitedResource; fix handle table def, for the moment
This commit is contained in:
parent
ac6762bb6c
commit
4a1021f220
6 changed files with 13 additions and 6 deletions
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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()
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue