From 27a8e91fa29d4a7319193a4ec1774ad1526b205c Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Thu, 11 May 2023 22:47:56 +0200 Subject: [PATCH] Job-Ticket: consider how to deal with channels and prerequisites By reasoning and analysis I conclude that the differentiation into multiple channels is likely misplaced in JobTicket; it belongs ratther into the Segment and should provide a suitable JobTicket for each ModelPort Handling of prerequisites also needs to be reshaped entirely after switching to a pipeline builder for the Job-planning pipeline; as preliminary access point, just add an iterator over the immediate prerequisites, thereby shifting the exploration mechanism entirely out of the JobTicket implementation --- src/lib/diff/gen-node.hpp | 8 + src/steam/engine/job-ticket.hpp | 21 +- src/steam/fixture/segment.hpp | 6 +- tests/core/steam/engine/mock-dispatcher.hpp | 61 +++-- tests/core/steam/engine/mock-support-test.cpp | 41 ++- wiki/renderengine.html | 34 +-- wiki/thinkPad.ichthyo.mm | 250 ++++++++++++++++-- 7 files changed, 359 insertions(+), 62 deletions(-) diff --git a/src/lib/diff/gen-node.hpp b/src/lib/diff/gen-node.hpp index da48b6cd4..696f988b5 100644 --- a/src/lib/diff/gen-node.hpp +++ b/src/lib/diff/gen-node.hpp @@ -472,6 +472,8 @@ namespace diff{ bool hasAttribute (string key) const; bool isNested() const; bool hasChildren() const; + Rec::scopeIter getChildren() const; + protected: @@ -817,6 +819,12 @@ namespace diff{ { return not isnil (data.childIter()); } + + inline Rec::scopeIter + GenNode::getChildren() const + { + return data.childIter(); + } diff --git a/src/steam/engine/job-ticket.hpp b/src/steam/engine/job-ticket.hpp index 563b385e3..f956e671b 100644 --- a/src/steam/engine/job-ticket.hpp +++ b/src/steam/engine/job-ticket.hpp @@ -44,6 +44,7 @@ #include "lib/hierarchy-orientation-indicator.hpp" #include "lib/linked-elements.hpp" #include "lib/iter-adapter.hpp" +#include "lib/itertools.hpp" #include "lib/meta/tuple-helper.hpp" #include "lib/meta/trait.hpp" #include "lib/util.hpp" @@ -121,7 +122,7 @@ using lib::LUID; }; - LinkedElements provision_; + LinkedElements provision_; //////////////////////////////////////////////////TICKET #1297 : retract differentiation into channels here (instead use ModelPorts in the Segment) template @@ -144,8 +145,18 @@ using lib::LUID; - ExplorationState startExploration() const; - ExplorationState discoverPrerequisites (uint channelNr =0) const; + ExplorationState startExploration() const; ////////////////////////////TICKET #1276 : likely to become obsolete + ExplorationState discoverPrerequisites (uint channelNr =0) const; ////////////////////////////TICKET #1276 : likely to become obsolete + + auto + getPrerequisites (uint slotNr =0) const + { + return lib::transformIterator (provision_[slotNr].requirements.begin() + ,[](Prerequisite& prq) -> JobTicket& + { + return prq.descriptor; + }); + } Job createJobFor (FrameCoord coordinates) const; @@ -301,7 +312,7 @@ using lib::LUID; ,"require at least specification for one channel"); LinkedElements provisionSpec; //////////////////////////////////////////////////TICKET #1292 : need to pass in Allocator as argument - for ( ; featureSpec; ++featureSpec) + for ( ; featureSpec; ++featureSpec) ///////////////////////////////////////////////////TICKET #1297 : this additional iteration over channels will go away { JobFunctor& func = std::get<0> (*featureSpec); HashVal invoSeed = std::get<1> (*featureSpec); @@ -309,7 +320,7 @@ using lib::LUID; for (Preq pre = std::get<2> (*featureSpec); pre; ++pre) provision.requirements.emplace (*pre); } - provisionSpec.reverse(); // retain order of given definitions per channel + provisionSpec.reverse(); // retain order of given definitions per channel ////////////TICKET #1297 : obsolete; instead we differentiate by OutputSlot in the Segment ENSURE (not isnil (provisionSpec)); return provisionSpec; } diff --git a/src/steam/fixture/segment.hpp b/src/steam/fixture/segment.hpp index 4e653b8e5..a15ad7fdf 100644 --- a/src/steam/fixture/segment.hpp +++ b/src/steam/fixture/segment.hpp @@ -66,7 +66,7 @@ namespace fixture { TimeSpan span_; /** render plan / blueprint to use for this segment */ - const engine::JobTicket* jobTicket_; + const engine::JobTicket* jobTicket_; ////////////////////////////////////////////////////TICKET #1297 : probably we'll get an array per ModelPort here ///////////////////////////////////////////////////////////////////////////////////////////////////////TICKET #725 : placeholder code /** relevant MObjects comprising this segment. */ @@ -78,7 +78,7 @@ namespace fixture { Segment (TimeSpan covered =TimeSpan::ALL ,const engine::JobTicket* ticket =nullptr) : span_{covered} - , jobTicket_{ticket? ticket : &engine::JobTicket::NOP} + , jobTicket_{ticket? ticket : &engine::JobTicket::NOP} //////////////////////////////////////////TICKET #1297 : ensure to provide a JobTicket for each ModelPort in initialisation { } Segment (Segment const& original, TimeSpan changed) @@ -92,7 +92,7 @@ namespace fixture { Time after() const { return span_.end(); } engine::JobTicket const& - jobTicket() const + jobTicket() const /////////////////////////////////////////////////////////////////TICKET #1297 : introduce additional key per ModelPort here { REQUIRE (jobTicket_); return *jobTicket_; diff --git a/tests/core/steam/engine/mock-dispatcher.hpp b/tests/core/steam/engine/mock-dispatcher.hpp index bdb68cf5d..1fc89d84f 100644 --- a/tests/core/steam/engine/mock-dispatcher.hpp +++ b/tests/core/steam/engine/mock-dispatcher.hpp @@ -42,6 +42,7 @@ #include "lib/diff/gen-node.hpp" #include "lib/depend.hpp" #include "lib/itertools.hpp" +//#include "lib/iter-tree-explorer.hpp" //#include "lib/util-coll.hpp" #include "vault/real-clock.hpp" #include "lib/test/test-helper.hpp" @@ -140,24 +141,21 @@ namespace test { + template inline auto - defineBottomSpec() + defineSpec (HashVal seed, IT&& prereq) { - auto emptyPrereq = lib::nilIterator(); - using Iter = decltype(emptyPrereq); - using SpecTuple = std::tuple; - return lib::singleValIterator( - SpecTuple(DummyJob::getFunctor(), 0, emptyPrereq)); + using SpecTuple = std::tuple; + return lib::singleValIterator( /////////////////////////////////////////////TICKET #1297 : multiplicity per channel will be removed here + SpecTuple(DummyJob::getFunctor() + , seed + , std::forward (prereq))); } inline auto - defineSimpleSpec (HashVal seed) /////////////////TODO collapse with defineBottomSpec() ?? + defineSimpleSpec (HashVal seed =0) { - auto emptyPrereq = lib::nilIterator(); - using Iter = decltype(emptyPrereq); - using SpecTuple = std::tuple; - return lib::singleValIterator( - SpecTuple(DummyJob::getFunctor(), seed, emptyPrereq)); + return defineSpec (seed, lib::nilIterator()); } }//(End)internal test helpers.... @@ -178,13 +176,18 @@ namespace test { public: MockJobTicket() - : JobTicket{defineBottomSpec()} + : JobTicket{defineSimpleSpec()} { } MockJobTicket (HashVal seed) : JobTicket{defineSimpleSpec (seed)} { } + template + MockJobTicket (HashVal seed, IT&& prereq) + : JobTicket{defineSpec (seed, std::forward (prereq))} + { } + bool verify_associated (Job const&) const; static bool isAssociated (Job const&, JobTicket const&); private: @@ -207,16 +210,38 @@ namespace test { { for (auto& spec : specs) { - JobTicket* newTicket = nullptr; - auto seed = spec.retrieveAttribute ("mark"); - tickets_.emplace_back (seed? HashVal(*seed) : HashVal(rand() % 1000)); - newTicket = & tickets_.back(); + JobTicket& newTicket = buildTicketFromSpec (spec); auto start = spec.retrieveAttribute