15#include <unordered_map>
34 explicit NodeCluster(std::vector<
Box<Node>>& nodes) : nodes(std::move(nodes)) { }
36 std::vector<Box<Node>> nodes;
44 auto hasEarlyTick() -> bool;
45 auto hasTick() -> bool;
46 auto hasPhysicsTick() -> bool;
47 auto hasPostPhysics() -> bool;
48 auto hasLateTick() -> bool;
52 using Wave = std::vector<std::variant<Box<Node>,
NodeCluster>>;
53 std::vector<Wave> early_tick;
54 std::vector<Wave> tick;
55 std::vector<Wave> physics_tick;
56 std::vector<Wave> post_physics;
57 std::vector<Wave> late_tick;
61using Interactions = std::unordered_map<Box<Node>, std::vector<Box<Node>>>;
71 -> std::vector<WaveJob>;
77 std::unordered_map<Box<Node>, std::vector<Box<Node>>>
connections;
87 auto unregisterDependency(
Node& from,
Node& to) -> bool;
113 void runPhase(
const std::vector<_detail::TickSchedule::Wave>& phase,
TickFunctionList func, std::string_view name)
const;
125 static void tickItem(
const _detail::TickSchedule::Wave::value_type& item,
TickFunctionList func);
129 const _detail::TickSchedule::Wave& wave,
const std::vector<_detail::WaveJob>& jobs,
TickFunctionList func,
int number
134 std::vector<_detail::WaveJob> jobs;
137 auto planFor(
const _detail::TickSchedule::Wave& wave,
TickFunctionList func)
const ->
const std::vector<_detail::WaveJob>&;
139 mutable std::unordered_map<const _detail::TickSchedule::Wave*, CachedPlan> m_plans;
142 auto subgraphSeparation(
const std::vector<
Box<Node>>& all_nodes) -> std::vector<std::vector<Box<Node>>>;
145 auto tarjanAlgorithm(
const std::vector<std::vector<
Box<Node>>>& input_subgraphs) -> std::vector<_detail::TickSchedule::Wave>;
148 auto assignWaves(
const std::vector<_detail::TickSchedule::Wave>& subgraphs) -> std::vector<_detail::TickSchedule::Wave>;
pseudo shared pointer for Nodes
Intrusive reference-counted handle to a Node.
Definition box.hpp:35
Definition tick_scheduler.hpp:74
void run() const
Runs the four frame phases (early_tick → tick → post_physics → late_tick) of the schedule.
Definition tick_scheduler.cpp:555
void runPhase(const std::vector< _detail::TickSchedule::Wave > &phase, TickFunctionList func, std::string_view name) const
Dispatches a single phase of the tick schedule.
Definition tick_scheduler.cpp:373
auto registerDependency(Node &from, Node &to) -> bool
Records a tick ordering constraint between two nodes.
Definition tick_scheduler.cpp:243
void runPhaseSerial(const std::vector< _detail::TickSchedule::Wave > &phase, TickFunctionList func, std::string_view name) const
Runs a phase wave by wave on the calling thread; for phases that touch thread-bound state like the ph...
Definition tick_scheduler.cpp:535
void runLifecycle(Node &root, TickFunctionList stage) const
Runs a lifecycle stage on root and every node below it, parents before their children.
Definition tick_scheduler.cpp:408
std::mutex graph_mutex
Scripts register dependencies from init().
Definition tick_scheduler.hpp:116
auto registerInteraction(Node &first, Node &second) -> bool
Records that the scripts of two nodes call each other.
Definition tick_scheduler.cpp:263
void compute(const std::vector< Box< Node > > &all_nodes)
Rebuilds the tick schedule from the given node set.
Definition tick_scheduler.cpp:298
_detail::Interactions interactions
The nodes that declared an interaction.
Definition tick_scheduler.hpp:121
Member-robber pattern used by the generated reflection code.
Definition defer.hpp:16
std::unordered_map< Box< Node >, std::vector< Box< Node > > > Interactions
For a node, the nodes whose scripts it calls or is called by, see Node::interactsWith().
Definition tick_scheduler.hpp:61
auto planWave(const TickSchedule::Wave &wave, TickFunctionList func, const Interactions *interactions) -> std::vector< WaveJob >
Splits a wave into the jobs that run it in parallel.
Definition tick_scheduler.cpp:203
Base object type for the scene graph.
TickFunctionList
Bit-flag set describing which lifecycle phases a Node type implements.
Definition reflect_node.hpp:36
Definition tick_scheduler.hpp:76
std::unordered_map< Box< Node >, std::vector< Box< Node > > > connections
forward edges (from → to)
Definition tick_scheduler.hpp:77
std::unordered_map< Box< Node >, std::vector< Box< Node > > > inverse_connections
reverse edges
Definition tick_scheduler.hpp:78
Definition tick_scheduler.hpp:33
Definition tick_scheduler.hpp:51
Runs a plan of jobs on the thread pool, one interpreter per job.