64 #ifndef SRC_VAULT_GEAR_ACTIVITY_H_ 65 #define SRC_VAULT_GEAR_ACTIVITY_H_ 103 explicit operator uint32_t()
const {
return id_;}
104 explicit operator bool()
const {
return id_ != 0; }
132 : microTick_{_raw(time)}
182 ,
void* executionCtx) =0;
187 ,
void* executionCtx) =0;
189 virtual Time getDeadline()
const =0;
194 return "Activity::Hook";
197 operator std::string()
const 290 bool isDead (
Time now)
const {
return dead <= now;}
291 bool isHold ()
const {
return rest > 0; }
292 bool isFree (
Time now)
const {
return not (isHold() or isDead(now)); }
293 Time getDeadline()
const {
return Time{dead}; }
294 void incDependencies() { ++rest; }
299 auto oldDeadline{dead};
301 return Time{oldDeadline};
346 setDefaultArg (verb);
354 Activity (uint64_t o1, uint64_t o2) noexcept
364 data_.invocation.task = &job;
365 data_.invocation.time = nominalTime;
373 data_.notification.target = target;
374 data_.notification.timing = limitWhen;
381 data_.condition.
rest = expectNotifications;
382 data_.condition.
dead = deadline;
389 data_.timeWindow = {when,when};
396 data_.timeWindow = {start,after};
402 data_.callback.hook = &callback;
403 data_.callback.arg = arg;
411 operator std::string()
const;
413 std::string showVerb()
const;
414 std::string showData()
const;
433 return expectedVerb == this->verb_;
440 data_.condition.incDependencies();
446 REQUIRE (is (NOTIFY));
447 data_.notification.target = target;
448 data_.notification.timing = limitStart;
454 return is(POST)? util::max (start,
Time{data_.timeWindow.life})
461 return is(POST)? util::min (death,
Time{data_.timeWindow.dead})
468 setDefaultArg (
Verb verb) noexcept
480 data_.condition.
rest = 1;
494 invokeFunktor (
Time) noexcept
496 REQUIRE (verb_ == INVOKE);
498 REQUIRE (next->verb_ == FEED);
499 REQUIRE (next->
next);
500 REQUIRE (next->
next->verb_ == FEED);
501 REQUIRE (data_.invocation.task);
504 lumiera_jobParameter param;
505 param.nominalTime = _raw(
Time{data_.invocation.time});
506 param.invoKey.code.w1 = next->data_.feed.one;
507 param.invoKey.code.w2 = next->data_.feed.two;
510 functor.invokeJobOperation (param);
514 return activity::PASS;
520 signalStart (
Time now, EXE& executionCtx)
522 executionCtx.work (now, data_.timing.quality);
523 return activity::PASS;
528 signalStop (
Time now, EXE& executionCtx)
530 executionCtx.done (now, data_.timing.quality);
531 return activity::PASS;
536 checkGate (
Time now, EXE&)
538 REQUIRE (GATE == verb_);
539 if (data_.condition.isDead(now))
540 return activity::SKIP;
541 if (data_.condition.isHold())
542 return activity::SKIP;
544 return activity::PASS;
548 receiveGateNotification (
Time now)
550 REQUIRE (GATE == verb_);
551 if (data_.condition.
rest > 0)
553 --data_.condition.
rest;
555 if (data_.condition.isFree(now))
557 data_.condition.lockPermanently();
558 return activity::PASS;
560 return activity::SKIP;
565 postSelf (
Time now, EXE& executionCtx)
569 return executionCtx.post (
Time{data_.timeWindow.life},
Time{data_.timeWindow.dead},
this, executionCtx);
571 return executionCtx.post (now,
Time::NEVER,
this, executionCtx);
576 postNotify (
Time now, EXE& executionCtx)
578 REQUIRE (is(NOTIFY));
579 Activity* target = data_.notification.target;
581 REQUIRE (not target->is(HOOK) or target->data_.callback.hook);
582 Time startHint = target->is(GATE) or
583 target->is(HOOK)?
Time{data_.notification.timing}
585 Time deadline = target->is(GATE)? target->data_.condition.getDeadline()
586 : target->is(HOOK)? target->data_.callback.hook->getDeadline()
589 return executionCtx.post (startHint,deadline, target, executionCtx);
594 callHook (
Time now, EXE& executionCtx)
596 return data_.callback.hook? data_.callback.hook->
activation(*
this, now, &executionCtx)
602 notifyHook (
Time now, EXE& executionCtx)
604 return data_.callback.hook? data_.callback.hook->
notify (*
this, now, &executionCtx)
610 doTick (
Time now, EXE& executionCtx)
612 return executionCtx.tick (now);
637 activity::_verify_usable_as_ExecutionContext<EXE>();
641 return invokeFunktor (now);
643 return signalStart (now, executionCtx);
645 return signalStop (now, executionCtx);
647 return postNotify (now, executionCtx);
649 return postSelf (now, executionCtx);
651 return checkGate (now, executionCtx);
653 return activity::PASS;
655 return callHook (now, executionCtx);
657 return doTick (now, executionCtx);
659 NOTREACHED (
"uncovered Activity verb in activation function.");
687 activity::_verify_usable_as_ExecutionContext<EXE>();
692 return activity::PASS;
694 return receiveGateNotification (now);
696 return notifyHook (now, executionCtx);
698 return activate (now, executionCtx);
static const Time ANYTIME
border condition marker value. ANYTIME <= any time value
a mutable time value, behaving like a plain number, allowing copy and re-accessing ...
Time window to define for activation.
Record to describe an Activity, to happen within the Scheduler's control flow.
< special definitions for the Scheduler activity language
#define ON_EXCEPTION_RETURN(_VAL_, _OP_DESCR_)
convenience shortcut to catch and absorb any exception, then returning a default value instead...
Extension point to invoke.
Access gate condition to evaluate.
abandon this play / render process
#define ASSERT_MEMBER_FUNCTOR(_EXPR_, _SIG_)
Macro for a compile-time check to verify some member is present and comprises something invokable wit...
int rest
alive while rest > 0
constexpr void _verify_usable_as_ExecutionContext()
Definition to emulate a Concept for the Execution Context.
Time constrainedDeath(Time death)
activity::Proc activate(Time now, EXE &executionCtx)
Core Operation: Activate and perform this Activity.
Lumiera's internal time value datatype.
virtual Proc notify(Activity &thisHook, Time now, void *executionCtx)=0
Callback when dispatching a NOTIFY-Activity to thisHook.
Marker for current (and obsolete) manifestations of a CalcStream processed by the Render-Engine...
Metaprogramming tools for transforming functor types.
External work functor to activate.
Verb
All possible kinds of activities.
nothing to do; wait and re-check for work later
Extension point to invoke a callback from Activity activation.
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...
pass on the activation down the chain
back pressure; get out of the way but be back soon
activity::Proc dispatch(Time now, EXE &executionCtx)
Entrance point for an activation, which has been dispatched indirectly through the dispatch and/or pr...
Activity * next
Activities are organised into chains to represent relations based on verbs.
Definition of a render job.
ExampleStrategy::Qualifier two(string additionalArg)
definition of another qualifier two(arg), accepting an additional argument
skip rest of the Activity chain for good
Basic set of definitions and includes commonly used together (Vault).
size_t HashVal
a STL compatible hash value
static const Time NEVER
border condition marker value. NEVER >= any time value
Interface of the closure for frame rendering jobs.
Offset measures a distance in time.
virtual Proc activation(Activity &thisHook, Time now, void *executionCtx)=0
Callback on activation of the corresponding HOOK-Activity.
Instant dead
alive while time < dead
Timing observation to propagate.
Proc
Result instruction from Activity activation.
ExampleStrategy::Qualifier one()
definition of a qualifier one()
a family of time value like entities and their relationships.
basic constant internal time value.
Storage of Argument data dependent on Activity::verb_.
Time constrainedStart(Time start)
Vault-Layer implementation namespace root.
Notification towards another Activity.