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 <mesosphere/core/KAutoObject.hpp>
#include <tuple> #include <tuple>
#define MESOSPHERE_LIMITED_RESOURCE_TRAITS(maxTime) static constexpr auto maxResourceAcqWaitTime = maxTime;
namespace mesosphere 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 { class ILimitedResource {
public: public:
static constexpr auto maxResourceAcqWaitTime = maxResourceAcqWaitTimeMsec * 1ms;
const SharedPtr<KProcess>& GetResourceOwner() const { return resourceOwner; } const SharedPtr<KProcess>& GetResourceOwner() const { return resourceOwner; }
void SetResourceOwner(SharedPtr<KProcess> owner) void SetResourceOwner(SharedPtr<KProcess> owner)
{ {

View File

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

View File

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

View File

@ -6,6 +6,7 @@ class KResourceLimit;
#include <mesosphere/core/util.hpp> #include <mesosphere/core/util.hpp>
#include <mesosphere/core/KAutoObject.hpp> #include <mesosphere/core/KAutoObject.hpp>
#include <mesosphere/interfaces/ISetAllocated.hpp> #include <mesosphere/interfaces/ISetAllocated.hpp>
#include <mesosphere/processes/KHandleTable.hpp>
namespace mesosphere namespace mesosphere
{ {
@ -28,6 +29,7 @@ class KProcess : public KAutoObject {
long schedulerOperationCount = -1; long schedulerOperationCount = -1;
SharedPtr<KResourceLimit> reslimit{}; SharedPtr<KResourceLimit> reslimit{};
KHandleTable handleTable{};
}; };
inline void intrusive_ptr_add_ref(KProcess *obj) 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 : class KThread final :
public KAutoObject, public KAutoObject,
public ILimitedResource<KThread, 100u>, public ILimitedResource<KThread>,
public ISetAllocated<KThread>, public ISetAllocated<KThread>,
public IAlarmable, public IAlarmable,
public ThreadWaitListBaseHook, public ThreadWaitListBaseHook,
@ -31,6 +31,7 @@ class KThread final :
public: public:
MESOSPHERE_AUTO_OBJECT_TRAITS(AutoObject, Thread); MESOSPHERE_AUTO_OBJECT_TRAITS(AutoObject, Thread);
MESOSPHERE_LIMITED_RESOURCE_TRAITS(100ms);
class StackParameters { class StackParameters {
public: public:

View File

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