Simplify asset loader lifecycle and paused scheduling

Make the loading lifecycle easier to follow by ordering functions by phase, splitting completion handling by asset type, and sharing color and texture preparation. Use Piece terminology, rename model rebuilding, and document reference and waiting behavior.

Keep pending work in the normal queues while paused, refresh piece snapshots before resuming, and remove duplicate enqueue and cancellation paths. QueuePiece now explicitly schedules background work.

Validated with a Debug build, 14 CLI export checks, and a temporary lifecycle harness covering staging resets, style refresh, cancellation, eight in-flight pause/resume cycles, last-consumer release, and shutdown.
This commit is contained in:
Leonardo Zide committed 2026-10-13 19:32:12 -07:00
1 parent 232fc54dee
commit 2051eeed42
6 files changed
+1073 -1135

No files matched your search

+12
View File
@@ -275,6 +275,14 @@ caller omits unavailable geometry, while the loading indicator exposes errors.
## A request from acquisition to notification
The loader implementation follows this lifecycle: request acquisition and queueing,
worker scheduling and `RunWorker()`, UI-thread `ProcessCompletions()` dispatch to
`CompletePiece()`, `CompleteSynth()`, or `CompleteTexture()`, dependency settlement
and publication, then deferred notifications. Readiness waits follow these paths;
invalidation, pause/resume, and shutdown are grouped at the end of the file.
Piece and synth handlers share color preparation and texture dependency checks,
while keeping their distinct ownership and publication rules explicit.
```mermaid
sequenceDiagram
participant Caller as Caller / UI thread
@@ -503,6 +511,10 @@ open discards the candidate. A successful switch releases old owners, cancels
old-only queued work, and preserves shared asset identities and requests. Neither
path demotes request priorities.
Pending jobs remain in the normal piece, texture, and synth queues while paused;
`mPaused` prevents dispatch. Resume refreshes queued piece source snapshots before
allowing workers to take jobs again.
Stud-style changes pause dispatch, finish running phases, discard staging built
with old settings, refresh sources, and rebuild affected published meshes and
generated geometry. The existing style-change path resumes and drains work.