// SPDX-FileCopyrightText: 2023 Unity Technologies and the glTFast authors // SPDX-License-Identifier: Apache-2.0 using System.Threading.Tasks; namespace GLTFast { /// /// An IDeferAgent decides whether to interrupt a preempt-able procedure /// running on the main thread at the current point in time. /// This decision manages the trade-off between minimum procedure duration /// and a responsive frame rate. /// public interface IDeferAgent { /// /// This will be called at various points in the loading procedure. /// /// True if the remaining work of the loading procedure should /// be deferred to the next frame/Update loop invocation. False if /// work can continue. bool ShouldDefer(); /// /// Indicates if upcoming work should be deferred to the next frame. /// /// Predicted duration of upcoming processing in seconds /// True if the remaining work of the loading procedure should /// be deferred to the next frame/Update loop invocation. False if /// work can continue. bool ShouldDefer(float duration); /// /// Conditional yield. May continue right away or yield once, based on time. /// /// If returns true, returns Task.Yield(). Otherwise returns sync Task BreakPoint(); /// /// Conditional yield. May continue right away or yield once, based on time and duration. /// /// Predicted duration of upcoming processing in seconds /// If returns true, returns Task.Yield(). Otherwise returns sync Task BreakPoint(float duration); } }