ecs/hstage
heterogeneous (cross-world) system scheduler.
Since: E2c sized-scheduler direction 2
WorldSystem
(defstruct WorldSystem [])
a System bound to one world (world-id + boxed handle).
Since: direction 2
make-world-system
(make-world-system)
bundle a (world-id, masks, run-fn, world) tuple.
Since: direction 2
bind-system
(bind-system [sys : System world-id : int world : int] :)
lift a `System` into a `WorldSystem` bound to a
| sys | the System (carries masks + run-fn) | |
| world-id | which world this system targets (conflict key) | |
| world | the system's own boxed world handle (:int carrier) |
Since: direction 2
world-system-conflicts?
(world-system-conflicts? [a : WorldSystem b : WorldSystem] :)
true if two WorldSystems cannot run
Since: direction 2
HStage
(HStage)
heap container for a list of WorldSystems, pre-grouped into
Since: direction 2
hstage-new
(hstage-new :)
allocate an empty HStage.
Since: direction 2
hstage-len
(hstage-len [s : HStage] :)
count of WorldSystems added.
Since: direction 2
hstage-add!
(hstage-add! [s : HStage sys : WorldSystem] :)
append a WorldSystem. Invalidates the wave partition.
Since: direction 2
hstage-n-waves
(hstage-n-waves [s : HStage] :)
count of waves, recomputing the partition if stale.
Since: direction 2
hstage-run!
(hstage-run! [s : HStage] :)
run every WorldSystem, each against its bound world.
Since: direction 2
hstage-free!
(hstage-free! [s : HStage] :)
release the HStage's backing arrays.
Since: direction 2
Internal definitions
hstage-task-- pthread-callable worker. Reads {fn, world} from arg and__hstage-recompute-waves-- internal: greedy first-fit grouping with__hstage-run-wave-raw-- dispatch the systems in `wave-idx`__hstage-dirty?-- internal: is the wave partition stale?