Activity-Lang: scaffolding to create a simple Term
This commit is contained in:
parent
8e20fa6de1
commit
e98fe1e78b
5 changed files with 422 additions and 736 deletions
|
|
@ -76,15 +76,27 @@ namespace gear {
|
|||
|
||||
// using default copy/assignment
|
||||
|
||||
|
||||
/**
|
||||
* Builder-API: initiate definition of render activities for a media calculation job.
|
||||
*/
|
||||
activity::Term
|
||||
buildCalculationJob (Job job, Time start, Time deadline)
|
||||
{
|
||||
return setupActivityScheme (activity::Term::CALC_JOB, job, start, deadline);
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
/** @internal generate the builder / configurator term */
|
||||
activity::Term
|
||||
setupActivityScheme (activity::Term::Template schemeKind, Time start, Time after)
|
||||
setupActivityScheme (activity::Term::Template schemeKind, Job job, Time start, Time after)
|
||||
{
|
||||
return activity::Term{ mem_.until(after)
|
||||
, schemeKind
|
||||
, start
|
||||
, after
|
||||
, job
|
||||
};
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@
|
|||
|
||||
#include "vault/gear/activity.hpp"
|
||||
#include "vault/gear/block-flow.hpp"
|
||||
#include "vault/gear/job.h"
|
||||
//#include "lib/symbol.hpp"
|
||||
#include "lib/time/timevalue.hpp"
|
||||
//#include "lib/util.hpp"
|
||||
|
|
@ -80,6 +81,9 @@ namespace gear {
|
|||
|
||||
AllocHandle alloc_;
|
||||
|
||||
Activity* invoke_{nullptr};
|
||||
Activity* post_{nullptr};
|
||||
|
||||
public:
|
||||
enum Template {CALC_JOB ///< scheme for a synchronous media calculation job
|
||||
,LOAD_JOB ///< scheme for an asynchronous data retrieval job
|
||||
|
|
@ -87,7 +91,7 @@ namespace gear {
|
|||
};
|
||||
|
||||
explicit
|
||||
Term (AllocHandle&& allocHandle, Template kind, Time start, Time after)
|
||||
Term (AllocHandle&& allocHandle, Template kind, Time start, Time after, Job job)
|
||||
: alloc_{move (allocHandle)}
|
||||
{ }
|
||||
|
||||
|
|
@ -101,6 +105,13 @@ namespace gear {
|
|||
// {
|
||||
// return diagnostic();
|
||||
// }
|
||||
|
||||
Activity&
|
||||
post()
|
||||
{
|
||||
REQUIRE (post_, "Activity Term not yet fully configured");
|
||||
return *post_;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@
|
|||
|
||||
|
||||
#include "vault/common.hpp"
|
||||
//#include "lib/test/test-helper.hpp"
|
||||
#include "lib/test/test-helper.hpp"
|
||||
#include "lib/test/event-log.hpp"
|
||||
|
||||
//#include "steam/play/dummy-play-connection.hpp"
|
||||
|
|
@ -499,6 +499,19 @@ namespace test {
|
|||
buildDiagnosticFun<SIG_JobDiagnostic> (id));
|
||||
}
|
||||
|
||||
Job
|
||||
buildMockJob (string id =""
|
||||
,Time nominal = lib::test::randTime()
|
||||
,size_t extra = rand())
|
||||
{
|
||||
InvocationInstanceID invoKey;
|
||||
invoKey.part.a = extra;
|
||||
invoKey.part.t = _raw(nominal);
|
||||
return Job{buildMockJobFunctor (isnil(id)? "mockJob-"+util::toString(nominal) : id)
|
||||
,invoKey
|
||||
,nominal};
|
||||
}
|
||||
|
||||
/** build a rigged HOOK-Activity to record each invocation */
|
||||
Activity&
|
||||
buildActivationProbe (string id)
|
||||
|
|
|
|||
|
|
@ -350,11 +350,23 @@ namespace test {
|
|||
|
||||
|
||||
/** @test TODO verify the Activity term builder
|
||||
* @todo WIP 7/23 ⟶ define ⟶ implement
|
||||
* @todo WIP 8/23 🔁 define ⟶ implement
|
||||
*/
|
||||
void
|
||||
termBuilder()
|
||||
{
|
||||
ActivityDetector detector;
|
||||
|
||||
BlockFlowAlloc bFlow;
|
||||
ActivityLang activityLang{bFlow};
|
||||
|
||||
Job job = detector.buildMockJob();
|
||||
Time start{0,1};
|
||||
Time dead{0,10};
|
||||
auto term = activityLang.buildCalculationJob (job,start,dead);
|
||||
|
||||
Activity& post = term.post();
|
||||
CHECK (Activity::POST == post.verb_);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue