feat(ecs): things_now / things_changed - a consumer keeps the tick it read up to and asks only for the Things written since (untouched 64-row blocks skipped)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Orkun ÇAKILKAYA 2026-09-27 22:13:45 +03:00
parent 61a6ab2e7b
commit 649a65d854
2 changed files with 35 additions and 0 deletions

View file

@ -15,3 +15,20 @@ export function things_drop_chunk(things_st: mut ThingsState, chunk: int) -> int
}
return n
}
# change detection: the tick now, the table moving on to the next - a consumer keeps what this
# returned and asks things_changed(since: it) for what was written after
export function things_now(things_st: mut ThingsState) -> int {
let t = tb_tick(things_st.th.tab)
tb_advance(things_st.th.tab)
return t
}
# every Thing a verb wrote after `since`, into the caller's list (untouched 64-row blocks skipped)
export function things_changed(things_st: ThingsState, since: int, rows: words, out: []Thing) -> int {
List.clear(out)
let tb = things_st.th.tab
let n = tb_changed_since(tb, since, rows)
for k in 0 .. n { push(out, tb.rec[rows[k]]) }
return n
}