StreamingManager class
Async job-batch manager for level loads, chunk activations, and future GPU asset transfers.
Batch lifecycle:
- BeginRequest() — opens a batch; internal counter initialised to 1 (gate ref).
- AddJob() × N — each call increments the counter and dispatches to TrinyxJobs.
- SubmitRequest() — releases the gate ref; callback fires on Tick() when counter hits 0.
All callbacks are fired from Tick(), which TrinyxEngine calls on the Sentinel thread. CopyPath() provides stable path storage inside the request (valid until the batch is released).
TODO: GPU push/pull helpers (mesh, material, shader, texture uploads / downloads).
Public functions
- auto BeginRequest(StreamingOnComplete onComplete, uint8_t ownerTag = 0) -> StreamingRequestID
-
template<TrinyxJobs::auto AddJob(StreamingRequestID id, LAMBDA lambda, TrinyxJobs::Queue queue = TrinyxJobs::Queue::General) -> bool
ValidJobLambda LAMBDA> - void SubmitRequest(StreamingRequestID id)
- Close the batch — releases the gate ref. Callback fires on the next Tick() once counter is 0.
- void Cancel(StreamingRequestID id)
- auto IsComplete(StreamingRequestID id) const -> bool
- Returns true once all jobs for this request have completed (or the request is unknown).
- auto CopyPath(StreamingRequestID id, const char* path) -> const char*
- void Tick()
- Drain completed batches and fire their callbacks. Call from the Sentinel tick.
Function documentation
StreamingRequestID StreamingManager:: BeginRequest(StreamingOnComplete onComplete,
uint8_t ownerTag = 0)
Open a new batch. Counter is held open at 1 until SubmitRequest. Pass ownerTag = GetLocalOwnerID() for OwnerSim worlds so PIENetThread can route the completion callback to the correct child handler.
template<TrinyxJobs:: ValidJobLambda LAMBDA>
bool StreamingManager:: AddJob(StreamingRequestID id,
LAMBDA lambda,
TrinyxJobs::Queue queue = TrinyxJobs::Queue::General)
Dispatch a job into the batch. Counter incremented once per call. All dispatched jobs must finish before the callback fires.
void StreamingManager:: Cancel(StreamingRequestID id)
Cancel an open batch without firing the callback. NOTE: if jobs are already in-flight the counter still drains; the slot is recycled once it reaches 0 on the next Tick(). Do not cancel after SubmitRequest.
const char* StreamingManager:: CopyPath(StreamingRequestID id,
const char* path)
Copy path into stable internal storage for use in job lambda captures. Call before AddJob. Pointer is valid until the request is released.