diff --git a/src/vault/mem/extent-family.hpp b/src/vault/mem/extent-family.hpp index 7746e0f0d..76819f6ec 100644 --- a/src/vault/mem/extent-family.hpp +++ b/src/vault/mem/extent-family.hpp @@ -61,7 +61,9 @@ namespace mem { // using util::isnil; // using std::string; - + template + class ExtentDiagnostic; + /** * Memory manager to provide a sequence of Extents for cyclic usage. @@ -123,9 +125,30 @@ namespace mem { extents_.reserve (expectedMaxExtents); } + void + openNew (size_t cnt) + { + UNIMPLEMENTED ("claim next cnt extents, possibly allocate"); + } + + void + dropOld (size_t cnt) + { + UNIMPLEMENTED ("discard oldest cnt extents"); + } + + /** allow transparent iteration of Extents, expanding storage on demand */ using iterator = lib::IterAdapter; ////////////////////OOO consider to use a Extent* instead of the RawIter?? + + iterator + active() + { + UNIMPLEMENTED ("visit all active extents, possibly claim next ones"); + } + + /* == Iteration control API (used by IterAdapter via ADL) == */ friend bool @@ -139,9 +162,31 @@ namespace mem { { UNIMPLEMENTED ("ExtentFamily iteration control: access next Extent, possibly expand allocation"); } + + friend class ExtentDiagnostic; }; + template + struct ExtentDiagnostic + { + using ExFam = ExtentFamily; + + ExFam& exFam_; + + size_t first() { return exFam_.start_; } + size_t last() { return exFam_.after_; } + size_t size() { return exFam_.extents_.size(); } + size_t active() { UNIMPLEMENTED ("count active"); } + }; + + template + inline ExtentDiagnostic + watch (ExtentFamily& extentFamily) + { + return ExtentDiagnostic{extentFamily}; + } + }} // namespace vault::mem #endif /*SRC_VAULT_MEM_EXTENT_FAMILY_H_*/ diff --git a/tests/vault/mem/extent-family-test.cpp b/tests/vault/mem/extent-family-test.cpp index e9eea8e18..2d5b612cf 100644 --- a/tests/vault/mem/extent-family-test.cpp +++ b/tests/vault/mem/extent-family-test.cpp @@ -31,11 +31,11 @@ //#include "lib/format-cout.hpp" //#include "lib/util.hpp" -//#include +#include using test::Test; //using std::move; -//using util::isSameObject; +using util::isSameObject; namespace vault{ @@ -46,6 +46,10 @@ namespace test { // using lib::time::Offset; // using lib::time::Time; + using Extents = ExtentFamily; + using Extent = Extents::Extent; + using Iter = Extents::iterator; + @@ -62,8 +66,9 @@ namespace test { run (Arg) { simpleUsage(); - calculateDeadline(); - setupDependentJob(); + use_and_drop(); + iteration(); + wrapAround(); } @@ -72,26 +77,79 @@ namespace test { void simpleUsage() { - ExtentFamily extents{5}; + Extents extents{5}; + Extent& extent = extents.active()->access(); //////////////////////////////////////////OOO better Iter implementation for direct access + CHECK (10 == extent.size()); + + int num = rand() % 1000; + extent[2] = num; + extent[5] = num+5; + CHECK (num == extent[2]); + CHECK (num+5 == extent[5]); } - /** @test verify the timing calculations to establish - * the scheduling deadline of a simple render job + /** @test verify claiming new and discarding old slots */ void - calculateDeadline() + use_and_drop() { + ExtentFamily extents{5}; + CHECK ( 0 == watch(extents).first()); + CHECK ( 0 == watch(extents).last()); + CHECK ( 0 == watch(extents).active()); + CHECK ( 5 == watch(extents).size()); + + extents.openNew(3); + CHECK ( 0 == watch(extents).first()); + CHECK ( 3 == watch(extents).last()); + CHECK ( 3 == watch(extents).active()); + CHECK ( 5 == watch(extents).size()); + + extents.dropOld(2); + CHECK ( 2 == watch(extents).first()); + CHECK ( 3 == watch(extents).last()); + CHECK ( 1 == watch(extents).active()); + CHECK ( 5 == watch(extents).size()); } - /** @test verify the setup of a prerequisite job in relation - * to the master job depending on this prerequisite + /** @test verify access to the extents by iteration, + * thereby possibly claiming the next extents */ void - setupDependentJob() + iteration() + { + Extents extents{5}; + Iter it = extents.active(); + CHECK (it); + + Extent& extent = it->access(); ////////////////////////////////////////////////////////OOO better Iter implementation for direct access + CHECK (10 == extent.size()); + + int num = rand() % 1000; + extent[2] = num; + CHECK (num == extent[2]); + + ++it; + CHECK (it); + Extent& nextEx = it->access(); + CHECK (not isSameObject(extent, nextEx)); + nextEx[5] = extent[2] + 1; + CHECK (num == extent[2]); + CHECK (num+1 == nextEx[5]); + } + + + + /** @test verify in detail how iteration wraps around to also reuse + * previously dropped extents, possibly rearranging the internal + * management-vector to allow growing new extents at the end. + */ + void + wrapAround() { } }; diff --git a/wiki/thinkPad.ichthyo.mm b/wiki/thinkPad.ichthyo.mm index df3f23932..6c4ce26c5 100644 --- a/wiki/thinkPad.ichthyo.mm +++ b/wiki/thinkPad.ichthyo.mm @@ -78506,9 +78506,9 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
- + - + @@ -78517,6 +78517,33 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
+ + + +
+ + + + + + + + + + + + + + + + + + + + + + +
@@ -78784,8 +78811,8 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
- - + + @@ -78829,7 +78856,7 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
- + @@ -79057,12 +79084,15 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
- + + + +