Class AsyncRequest<T>
Concrete AsyncRequest for specific type T.
Inherited Members
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
results
Array of asynchronous results.
Declaration
public AsyncRequest.Result[] results { get; }
Property Value
Type | Description |
---|---|
AsyncRequest.Result[] |
Methods
AllResultsAreCompleted()
All results are completed if...
- The request was started.
- There are no callbacks in flight.
- All results are marked completed.
Declaration
protected override bool AllResultsAreCompleted()
Returns
Type | Description |
---|---|
Boolean |
Overrides
AnyResultHasError()
Returns true if any of the results had an error.
Declaration
protected override bool AnyResultHasError()
Returns
Type | Description |
---|---|
Boolean |
Overrides
Complete()
Declaration
public override void Complete()
Overrides
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
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. |