From 4a1021f2201d465dc5d782e6f109ef7dc5e17bd9 Mon Sep 17 00:00:00 2001 From: TuxSH Date: Tue, 6 Nov 2018 00:16:33 +0100 Subject: [PATCH] Do the same for ILimitedResource; fix handle table def, for the moment --- .../include/mesosphere/interfaces/ILimitedResource.hpp | 6 +++--- mesosphere/include/mesosphere/processes/KEvent.hpp | 1 + mesosphere/include/mesosphere/processes/KHandleTable.hpp | 4 +++- mesosphere/include/mesosphere/processes/KProcess.hpp | 2 ++ mesosphere/include/mesosphere/threading/KThread.hpp | 3 ++- mesosphere/source/processes/KHandleTable.cpp | 3 ++- 6 files changed, 13 insertions(+), 6 deletions(-) diff --git a/mesosphere/include/mesosphere/interfaces/ILimitedResource.hpp b/mesosphere/include/mesosphere/interfaces/ILimitedResource.hpp index 1f899694f..0da3b9c2e 100644 --- a/mesosphere/include/mesosphere/interfaces/ILimitedResource.hpp +++ b/mesosphere/include/mesosphere/interfaces/ILimitedResource.hpp @@ -4,6 +4,8 @@ #include #include +#define MESOSPHERE_LIMITED_RESOURCE_TRAITS(maxTime) static constexpr auto maxResourceAcqWaitTime = maxTime; + namespace mesosphere { @@ -15,12 +17,10 @@ void ReleaseResource(const SharedPtr &reslimit, KAutoObject::Typ } -template +template class ILimitedResource { public: - static constexpr auto maxResourceAcqWaitTime = maxResourceAcqWaitTimeMsec * 1ms; - const SharedPtr& GetResourceOwner() const { return resourceOwner; } void SetResourceOwner(SharedPtr owner) { diff --git a/mesosphere/include/mesosphere/processes/KEvent.hpp b/mesosphere/include/mesosphere/processes/KEvent.hpp index f0f6e833a..9c6d2636b 100644 --- a/mesosphere/include/mesosphere/processes/KEvent.hpp +++ b/mesosphere/include/mesosphere/processes/KEvent.hpp @@ -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(); diff --git a/mesosphere/include/mesosphere/processes/KHandleTable.hpp b/mesosphere/include/mesosphere/processes/KHandleTable.hpp index 01974e179..57aef5a92 100644 --- a/mesosphere/include/mesosphere/processes/KHandleTable.hpp +++ b/mesosphere/include/mesosphere/processes/KHandleTable.hpp @@ -2,6 +2,7 @@ #include #include +#include #include #include #include @@ -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: diff --git a/mesosphere/include/mesosphere/processes/KProcess.hpp b/mesosphere/include/mesosphere/processes/KProcess.hpp index 4817e0f0d..8a5a636ca 100644 --- a/mesosphere/include/mesosphere/processes/KProcess.hpp +++ b/mesosphere/include/mesosphere/processes/KProcess.hpp @@ -6,6 +6,7 @@ class KResourceLimit; #include #include #include +#include namespace mesosphere { @@ -28,6 +29,7 @@ class KProcess : public KAutoObject { long schedulerOperationCount = -1; SharedPtr reslimit{}; + KHandleTable handleTable{}; }; inline void intrusive_ptr_add_ref(KProcess *obj) diff --git a/mesosphere/include/mesosphere/threading/KThread.hpp b/mesosphere/include/mesosphere/threading/KThread.hpp index 09c08be69..6dcfdd04f 100644 --- a/mesosphere/include/mesosphere/threading/KThread.hpp +++ b/mesosphere/include/mesosphere/threading/KThread.hpp @@ -22,7 +22,7 @@ using ThreadMutexWaitListBaseHook = boost::intrusive::list_base_hook, + public ILimitedResource, public ISetAllocated, 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: diff --git a/mesosphere/source/processes/KHandleTable.cpp b/mesosphere/source/processes/KHandleTable.cpp index ed273b673..41b01fb23 100644 --- a/mesosphere/source/processes/KHandleTable.cpp +++ b/mesosphere/source/processes/KHandleTable.cpp @@ -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() {