maybe a breakthrough on the job planning design quest?
why the hell is getting this design about right such a chellenging task. Anyway, seems to be the first step ahead after numerous failed attempts
This commit is contained in:
parent
88f433f433
commit
a3bc69cc77
2 changed files with 172 additions and 72 deletions
|
|
@ -43,75 +43,25 @@
|
||||||
namespace proc {
|
namespace proc {
|
||||||
namespace engine {
|
namespace engine {
|
||||||
|
|
||||||
|
namespace error = lumiera::error;
|
||||||
|
|
||||||
//using lib::time::TimeSpan;
|
//using lib::time::TimeSpan;
|
||||||
//using lib::time::Duration;
|
//using lib::time::Duration;
|
||||||
//using lib::time::FSecs;
|
//using lib::time::FSecs;
|
||||||
//using lib::time::Time;
|
//using lib::time::Time;
|
||||||
//using lib::LinkedElements;
|
//using lib::LinkedElements;
|
||||||
using util::isnil;
|
using util::isnil;
|
||||||
|
using util::unConst;
|
||||||
//
|
//
|
||||||
//class ExitNode;
|
//class ExitNode;
|
||||||
|
|
||||||
class JobPlanning;
|
|
||||||
|
|
||||||
#if false /////////////////////////////////////////////////////////////////////////////////////////////////////////////UNIMPLEMENTED :: TICKET #827
|
|
||||||
class Evaluation
|
|
||||||
{
|
|
||||||
JobTicket::ExplorationStack focusPoint_;
|
|
||||||
FUN& explore_;
|
|
||||||
|
|
||||||
public:
|
|
||||||
/** inactive evaluation */
|
|
||||||
Evaluation()
|
|
||||||
{
|
|
||||||
UNIMPLEMENTED ("how to represent an inactive evaluation");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
JobPlanning &
|
|
||||||
getFeed ()
|
|
||||||
{
|
|
||||||
while (focusPoint_ && focusPoint_.currentLevelExhausted())
|
|
||||||
focusPoint_.pop();
|
|
||||||
|
|
||||||
return dressUp(this); /////////////TODO: bad smell
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
recurse ()
|
|
||||||
{
|
|
||||||
focusPoint_.visitPrerequisites();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* === Iteration control API for IterStateWrapper== */
|
|
||||||
|
|
||||||
friend bool
|
|
||||||
checkPoint (Evaluation const& eval)
|
|
||||||
{
|
|
||||||
return bool(seq.feed());
|
|
||||||
}
|
|
||||||
|
|
||||||
friend JobPlanning&
|
|
||||||
yield (Evaluation const& eval)
|
|
||||||
{
|
|
||||||
return *(seq.feed());
|
|
||||||
}
|
|
||||||
|
|
||||||
friend void
|
|
||||||
iterNext (Evaluation & eval)
|
|
||||||
{
|
|
||||||
seq.iterate();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
class JobPlanning
|
class JobPlanning
|
||||||
: public lib::IterStateWrapper<JobPlanning, Evaluation>
|
|
||||||
{
|
{
|
||||||
typedef lib::IterStateWrapper<JobPlanning, Evaluation> _Iter;
|
JobTicket::iterator plannedOperations_;
|
||||||
|
FrameCoord point_to_calculate_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/** by default create the bottom element of job planning,
|
/** by default create the bottom element of job planning,
|
||||||
|
|
@ -119,29 +69,147 @@ namespace engine {
|
||||||
* using an inactive state core (default constructed)
|
* using an inactive state core (default constructed)
|
||||||
*/
|
*/
|
||||||
JobPlanning()
|
JobPlanning()
|
||||||
{
|
{ }
|
||||||
UNIMPLEMENTED ("create the bottom job planning");
|
|
||||||
}
|
|
||||||
|
|
||||||
/** further job planning can be initiated by continuing
|
/** further job planning can be initiated by continuing
|
||||||
* off a given previous planning state. This is how
|
* off a given previous planning state. This is how
|
||||||
* the forks are created, expanding into a multitude
|
* the forks are created, expanding into a multitude
|
||||||
* of prerequisites of a given job
|
* of prerequisites of a given job
|
||||||
*/
|
*/
|
||||||
JobPlanning (Evaluation const& startingPoint)
|
JobPlanning (JobTicket::iterator const& startingPoint, FrameCoord requestedFrame)
|
||||||
: _Iter(startingPoint)
|
: plannedOperations_(startingPoint)
|
||||||
|
, point_to_calculate_(requestedFrame)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
// operator Evaluation&()
|
// using the standard copy operations
|
||||||
// {
|
|
||||||
// return stateCore();
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
|
/** cast and explicate this job planning information
|
||||||
|
* to create a frame job descriptor, ready to be scheduled
|
||||||
|
*/
|
||||||
operator Job()
|
operator Job()
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED ("yield a Job descriptor to reflect this planning information");
|
if (isnil (plannedOperations_))
|
||||||
|
throw error::Logic("Attempt to plan a frame-Job based on a missing, "
|
||||||
|
"unspecified, exhausted or superseded job description"
|
||||||
|
,error::LUMIERA_ERROR_BOTTOM_VALUE);
|
||||||
|
|
||||||
|
return plannedOperations_->createJobFor (point_to_calculate_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** build a new JobPlanning object,
|
||||||
|
* set to explore the prerequisites
|
||||||
|
* at the given planning situation
|
||||||
|
*/
|
||||||
|
JobPlanning
|
||||||
|
discoverPrerequisites() const
|
||||||
|
{
|
||||||
|
if (isnil (plannedOperations_))
|
||||||
|
return JobPlanning();
|
||||||
|
else
|
||||||
|
return JobPlanning (plannedOperations_->discoverPrerequisites()
|
||||||
|
,this->point_to_calculate_);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* === Iteration control API for IterStateWrapper== */
|
||||||
|
|
||||||
|
friend bool
|
||||||
|
checkPoint (JobPlanning const& plan)
|
||||||
|
{
|
||||||
|
return !isnil (plan.plannedOperations_);
|
||||||
|
}
|
||||||
|
|
||||||
|
friend JobPlanning&
|
||||||
|
yield (JobPlanning const& plan)
|
||||||
|
{
|
||||||
|
REQUIRE (checkPoint (plan));
|
||||||
|
return unConst(plan);
|
||||||
|
}
|
||||||
|
|
||||||
|
friend void
|
||||||
|
iterNext (JobPlanning & plan)
|
||||||
|
{
|
||||||
|
++plan.plannedOperations_;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
#if false /////////////////////////////////////////////////////////////////////////////////////////////////////////////UNIMPLEMENTED :: TICKET #827
|
||||||
|
|
||||||
|
|
||||||
|
class PlanningState
|
||||||
|
: public lib::IterStateWrapper<JobPlanning>
|
||||||
|
{
|
||||||
|
typedef lib::IterStateWrapper<JobPlanning> _Iter;
|
||||||
|
|
||||||
|
JobTicket::ExplorationStack explorationStack_;
|
||||||
|
|
||||||
|
public:
|
||||||
|
/** inactive evaluation */
|
||||||
|
PlanningState()
|
||||||
|
: _Iter()
|
||||||
|
, explorationStack_()
|
||||||
|
{ }
|
||||||
|
|
||||||
|
explicit
|
||||||
|
PlanningState (JobPlanning const& startingPoint)
|
||||||
|
: _Iter(startingPoint) // note: invoking copy ctor on state core
|
||||||
|
, explorationStack_()
|
||||||
|
{ }
|
||||||
|
|
||||||
|
// using the standard copy operations
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/** attach and integrate the given planning details into this planning state.
|
||||||
|
* Actually the evaluation proceeds depth-first with the other state, returning
|
||||||
|
* later on to the current position for further evaluation */
|
||||||
|
PlanningState &
|
||||||
|
wrapping (JobPlanning const& startingPoint)
|
||||||
|
{
|
||||||
|
explorationStack_.push (stateCore());
|
||||||
|
stateCore() = startingPoint;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
PlanningState &
|
||||||
|
usingSequence (PlanningState const& prerequisites)
|
||||||
|
{
|
||||||
|
if (isnil (prerequisites))
|
||||||
|
return *this;
|
||||||
|
else
|
||||||
|
return this->wrapping(*prerequisites);
|
||||||
|
}
|
||||||
|
|
||||||
|
///TODO what elements are accepted by the explorationStack? provide conversion operator to extract those from stateCore()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/** Extension point to be picked up by ADL.
|
||||||
|
* Provides access for the JobPlanningSequence
|
||||||
|
* for combining and expanding partial results.
|
||||||
|
*/
|
||||||
|
friend PlanningState&
|
||||||
|
build (PlanningState& attachmentPoint)
|
||||||
|
{
|
||||||
|
return attachmentPoint;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
inline PlanningState
|
||||||
|
expandPrerequisites (JobPlanning const& calculationStep)
|
||||||
|
{
|
||||||
|
PlanningState newSubEvaluation(
|
||||||
|
calculationStep.discoverPrerequisites());
|
||||||
|
return newSubEvaluation;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -178,12 +246,6 @@ namespace engine {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
inline JobPlanning
|
|
||||||
explorePrerequisites(JobPlanning step)
|
|
||||||
{
|
|
||||||
Evaluation planningState_(step);
|
|
||||||
return planningState_.explorePrerequisites();
|
|
||||||
}
|
|
||||||
#endif /////////////////////////////////////////////////////////////////////////////////////////////////////////////UNIMPLEMENTED :: TICKET #827
|
#endif /////////////////////////////////////////////////////////////////////////////////////////////////////////////UNIMPLEMENTED :: TICKET #827
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@
|
||||||
//#include "lib/time/timevalue.hpp"
|
//#include "lib/time/timevalue.hpp"
|
||||||
//#include "lib/time/timequant.hpp"
|
//#include "lib/time/timequant.hpp"
|
||||||
#include "lib/linked-elements.hpp"
|
#include "lib/linked-elements.hpp"
|
||||||
|
#include "lib/iter-adapter.hpp"
|
||||||
|
|
||||||
#include <boost/noncopyable.hpp>
|
#include <boost/noncopyable.hpp>
|
||||||
|
|
||||||
|
|
@ -105,10 +106,38 @@ using lib::LinkedElements;
|
||||||
struct Prerequisites ///< per channel
|
struct Prerequisites ///< per channel
|
||||||
{
|
{
|
||||||
Prerequisites* next;
|
Prerequisites* next;
|
||||||
LinkedElements<Prerequisite> preparations_;
|
LinkedElements<Prerequisite> requiredJobs_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
struct PrerequisitesDiscovery
|
||||||
|
{
|
||||||
|
/////////////TODO
|
||||||
|
|
||||||
|
/* === Iteration control API for IterStateWrapper== */
|
||||||
|
|
||||||
|
friend bool
|
||||||
|
checkPoint (PrerequisitesDiscovery const& plan)
|
||||||
|
{
|
||||||
|
UNIMPLEMENTED ("detect end of prerequisites");
|
||||||
|
}
|
||||||
|
|
||||||
|
friend JobTicket&
|
||||||
|
yield (PrerequisitesDiscovery const& plan)
|
||||||
|
{
|
||||||
|
UNIMPLEMENTED ("access prerequisite and follow up to prerequisite JobTicket");
|
||||||
|
}
|
||||||
|
|
||||||
|
friend void
|
||||||
|
iterNext (PrerequisitesDiscovery & plan)
|
||||||
|
{
|
||||||
|
UNIMPLEMENTED ("step ahead to next prerequisite");
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
LinkedElements<Provision> channelConfig_;
|
LinkedElements<Provision> channelConfig_;
|
||||||
LinkedElements<Prerequisites> requirement_;
|
LinkedElements<Prerequisites> requirement_;
|
||||||
|
|
||||||
|
|
@ -118,12 +147,21 @@ using lib::LinkedElements;
|
||||||
|
|
||||||
friend class ExplorationStack;
|
friend class ExplorationStack;
|
||||||
|
|
||||||
|
typedef lib::IterStateWrapper<JobTicket, PrerequisitesDiscovery> iterator;
|
||||||
|
|
||||||
|
|
||||||
JobTicket()
|
JobTicket()
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED ("job representation, planning and scheduling");
|
UNIMPLEMENTED ("job representation, planning and scheduling");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
iterator
|
||||||
|
discoverPrerequisites() const
|
||||||
|
{
|
||||||
|
UNIMPLEMENTED("delve into the requirement_ datastructure");
|
||||||
|
}
|
||||||
|
|
||||||
Job createJobFor (FrameCoord coordinates);
|
Job createJobFor (FrameCoord coordinates);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue