docs.unity3d.com
    Show / Hide Table of Contents

    Class AsyncRequest<T>

    Concrete AsyncRequest for specific type T.

    Inheritance
    Object
    AsyncRequest
    AsyncRequest<T>
    Inherited Members
    AsyncRequest.defaultExecutionContext
    AsyncRequest.maxJobSystemParallelism
    AsyncRequest.maxAsyncRequestFrameAge
    AsyncRequest.requestFrameAgeToAutoComplete
    AsyncRequest.started
    AsyncRequest.error
    AsyncRequest.completed
    AsyncRequest._state
    AsyncRequest._executionContext
    AsyncRequest._executionHandles
    Namespace: Unity.Simulation
    Syntax
    public class AsyncRequest<T> : AsyncRequest, IDisposable
    Type Parameters
    Name Description
    T

    Constructors

    AsyncRequest()

    Default constructor for AsyncRequest.

    Declaration
    public AsyncRequest()

    Properties

    data

    Returns a reference to the payload for this request.

    Declaration
    public ref T data { get; }
    Property Value
    Type Description
    T

    jobsInFlight

    Declaration
    public override int jobsInFlight { get; }
    Property Value
    Type Description
    Int32
    Overrides
    AsyncRequest.jobsInFlight

    results

    Array of asynchronous results.

    Declaration
    public AsyncRequest.Result[] results { get; }
    Property Value
    Type Description
    AsyncRequest.Result[]

    Methods

    AllResultsAreCompleted()

    All results are completed if...

    1. The request was started.
    2. There are no callbacks in flight.
    3. All results are marked completed.
    Declaration
    protected override bool AllResultsAreCompleted()
    Returns
    Type Description
    Boolean
    Overrides
    AsyncRequest.AllResultsAreCompleted()

    AnyResultHasError()

    Returns true if any of the results had an error.

    Declaration
    protected override bool AnyResultHasError()
    Returns
    Type Description
    Boolean
    Overrides
    AsyncRequest.AnyResultHasError()

    Complete()

    Declaration
    public override void Complete()
    Overrides
    AsyncRequest.Complete()

    Dispose()

    Disposes the request. This will add the request back to the object pool.

    Declaration
    public void Dispose()

    DontCare(AsyncRequest<T>)

    You can use this method to complete a request without needing a lambda function. Passing null will likely cause work to be skipped, but passing this will do it and complete.

    Declaration
    public static AsyncRequest.Result DontCare(AsyncRequest<T> r)
    Parameters
    Type Name Description
    AsyncRequest<T> r
    Returns
    Type Description
    AsyncRequest.Result

    Enqueue(Func<AsyncRequest<T>, AsyncRequest.Result>)

    Queues a unit of work that can be executed on start.

    Declaration
    public void Enqueue(Func<AsyncRequest<T>, AsyncRequest.Result> functor)
    Parameters
    Type Name Description
    Func<AsyncRequest<T>, AsyncRequest.Result> functor

    A callback that needs to be invoked

    Execute(AsyncRequest.ExecutionContext)

    Starts executing all the queued callback functions in the given execution context.

    Declaration
    public void Execute(AsyncRequest.ExecutionContext executionContext = AsyncRequest.ExecutionContext.None)
    Parameters
    Type Name Description
    AsyncRequest.ExecutionContext executionContext

    Execution context in which the functions needs to be invoked.

    Finalize()

    Declaration
    protected void Finalize()

    Reset()

    Resets the request. Called when adding back to the object pool.

    Declaration
    public override void Reset()
    Overrides
    AsyncRequest.Reset()

    Start(Func<AsyncRequest<T>, AsyncRequest.Result>, AsyncRequest.ExecutionContext)

    Queues a callback that needs to be executed in the given execution context, and starts the request.

    Declaration
    [Obsolete("Start(Func<...>, ExecutionContext) is deprecated. Use Enqueue(Func<...>) + Execute(ExecutionContext) instead.")]
    public void Start(Func<AsyncRequest<T>, AsyncRequest.Result> functor = null, AsyncRequest.ExecutionContext executionContext = AsyncRequest.ExecutionContext.None)
    Parameters
    Type Name Description
    Func<AsyncRequest<T>, AsyncRequest.Result> functor

    A callback that needs to be invoked

    AsyncRequest.ExecutionContext executionContext

    Execution context in which the functor needs to be invoked. viz. Threadpool, EnoOfFrame or Immediate, etc.

    Operators

    Addition(AsyncRequest<T>, Func<AsyncRequest<T>, AsyncRequest.Result>)

    Operator overload for adding functors to the AsyncRequest queue.

    Declaration
    public static AsyncRequest<T> operator +(AsyncRequest<T> a, Func<AsyncRequest<T>, AsyncRequest.Result> b)
    Parameters
    Type Name Description
    AsyncRequest<T> a

    Current AsyncRequest

    Func<AsyncRequest<T>, AsyncRequest.Result> b

    Functor to be added

    Returns
    Type Description
    AsyncRequest<T>

    AsyncRequest with updated functors queue.

    Back to top
    Terms of use
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023