LoaderScheduler
Budgets the synchronous work the loader does while walking the package tree.
Bootstrapping recurses over every folder, module script and value in the tree in one go, which on a large game can exhaust Roblox's script execution timeout. Callers thread a scheduler through that recursion and call LoaderScheduler.YieldIfNeededAsync as they walk, which spreads the work over frames instead of blowing the whole budget at once.
Functions
new
LoaderScheduler.new(label: string,--
Names the walk being budgeted, for debug output
budgetBeforeYield: number?--
Seconds of work allowed before yielding
) → LoaderSchedulerConstructs a new scheduler with a fresh budget.
isLoaderScheduler
LoaderScheduler.isLoaderScheduler(loaderScheduler: any?) → booleanReturns true if the argument is a loader scheduler
RestartBudget
Starts the budget over without yielding. Use this when the caller has already yielded for its own reasons.
Pass a start time from LoaderScheduler.GetBudgetStartTime to continue a window another scheduler already opened, so work handed between schedulers inside one frame keeps counting against that frame instead of each walk being handed a full budget.
GetBudgetStartTime
When the current budget window started, or nil if none is open.
ClearBudget
Clears the budget so the next LoaderScheduler.YieldIfNeededAsync starts a fresh window. Use this when the walk is done, otherwise the next caller measures against however long ago we last yielded.
GetTotalComputeTime
Total time spent computing, excluding time spent yielded. Compare against wall clock time to see what the yielding is costing.
YieldIfNeededAsync
Yields if this frame's budget is spent, otherwise returns immediately.
Callers that yield here have to revalidate whatever they captured before the call, since the tree can change while we're yielded.