55 #ifndef SRC_VAULT_GEAR_ACTIVITY_H_ 56 #define SRC_VAULT_GEAR_ACTIVITY_H_ 94 explicit operator uint32_t()
const {
return id_;}
95 explicit operator bool()
const {
return id_ != 0; }
123 : microTick_{_raw(time)}
173 ,
void* executionCtx) =0;
178 ,
void* executionCtx) =0;
180 virtual Time getDeadline()
const =0;
185 return "Activity::Hook";
188 operator std::string()
const 281 bool isDead (
Time now)
const {
return dead <= now;}
282 bool isHold ()
const {
return rest > 0; }
283 bool isFree (
Time now)
const {
return not (isHold() or isDead(now)); }
284 Time getDeadline()
const {
return Time{dead}; }
285 void incDependencies() { ++rest; }
290 auto oldDeadline{dead};
292 return Time{oldDeadline};
337 setDefaultArg (verb);
345 Activity (uint64_t o1, uint64_t o2) noexcept
355 data_.invocation.task = &job;
356 data_.invocation.time = nominalTime;
364 data_.notification.target = target;
365 data_.notification.timing = limitWhen;
372 data_.condition.
rest = expectNotifications;
373 data_.condition.
dead = deadline;
380 data_.timeWindow = {when,when};
387 data_.timeWindow = {start,after};
393 data_.callback.hook = &callback;
394 data_.callback.arg = arg;
402 operator std::string()
const;
404 std::string showVerb()
const;
405 std::string showData()
const;
424 return expectedVerb == this->verb_;
431 data_.condition.incDependencies();
437 REQUIRE (is (NOTIFY));
438 data_.notification.target = target;
439 data_.notification.timing = limitStart;
445 return is(POST)? util::max (start,
Time{data_.timeWindow.life})
452 return is(POST)? util::min (death,
Time{data_.timeWindow.dead})
459 setDefaultArg (
Verb verb) noexcept
471 data_.condition.
rest = 1;
485 invokeFunktor (
Time) noexcept
487 REQUIRE (verb_ == INVOKE);
489 REQUIRE (next->verb_ == FEED);
490 REQUIRE (next->
next);
491 REQUIRE (next->
next->verb_ == FEED);
492 REQUIRE (data_.invocation.task);
495 lumiera_jobParameter param;
496 param.nominalTime = _raw(
Time{data_.invocation.time});
497 param.invoKey.code.w1 = next->data_.feed.one;
498 param.invoKey.code.w2 = next->data_.feed.two;
501 functor.invokeJobOperation (param);
505 return activity::PASS;
511 signalStart (
Time now, EXE& executionCtx)
513 executionCtx.work (now, data_.timing.quality);
514 return activity::PASS;
519 signalStop (
Time now, EXE& executionCtx)
521 executionCtx.done (now, data_.timing.quality);
522 return activity::PASS;
527 checkGate (
Time now, EXE&)
529 REQUIRE (GATE == verb_);
530 if (data_.condition.isDead(now))
531 return activity::SKIP;
532 if (data_.condition.isHold())
533 return activity::SKIP;
535 return activity::PASS;
539 receiveGateNotification (
Time now)
541 REQUIRE (GATE == verb_);
542 if (data_.condition.
rest > 0)
544 --data_.condition.
rest;
546 if (data_.condition.isFree(now))
548 data_.condition.lockPermanently();
549 return activity::PASS;
551 return activity::SKIP;
556 postSelf (
Time now, EXE& executionCtx)
560 return executionCtx.post (
Time{data_.timeWindow.life},
Time{data_.timeWindow.dead},
this, executionCtx);
562 return executionCtx.post (now,
Time::NEVER,
this, executionCtx);
567 postNotify (
Time now, EXE& executionCtx)
569 REQUIRE (is(NOTIFY));
570 Activity* target = data_.notification.target;
572 REQUIRE (not target->is(HOOK) or target->data_.callback.hook);
573 Time startHint = target->is(GATE) or
574 target->is(HOOK)?
Time{data_.notification.timing}
576 Time deadline = target->is(GATE)? target->data_.condition.getDeadline()
577 : target->is(HOOK)? target->data_.callback.hook->getDeadline()
580 return executionCtx.post (startHint,deadline, target, executionCtx);
585 callHook (
Time now, EXE& executionCtx)
587 return data_.callback.hook? data_.callback.hook->
activation(*
this, now, &executionCtx)
593 notifyHook (
Time now, EXE& executionCtx)
595 return data_.callback.hook? data_.callback.hook->
notify (*
this, now, &executionCtx)
601 doTick (
Time now, EXE& executionCtx)
603 return executionCtx.tick (now);
628 activity::_verify_usable_as_ExecutionContext<EXE>();
632 return invokeFunktor (now);
634 return signalStart (now, executionCtx);
636 return signalStop (now, executionCtx);
638 return postNotify (now, executionCtx);
640 return postSelf (now, executionCtx);
642 return checkGate (now, executionCtx);
644 return activity::PASS;
646 return callHook (now, executionCtx);
648 return doTick (now, executionCtx);
650 NOTREACHED (
"uncovered Activity verb in activation function.");
678 activity::_verify_usable_as_ExecutionContext<EXE>();
683 return activity::PASS;
685 return receiveGateNotification (now);
687 return notifyHook (now, executionCtx);
689 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.