Class AsyncRequest<T>
Concrete AsyncRequest for specific type T.
Implements
Inherited Members
Namespace: Unity.Simulation
Assembly: Unity.Simulation.Core.dll
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 |
|---|---|
| int |
Overrides
results
Array of asynchronous results.
Declaration
public AsyncRequest.Result[] results { get; }
Property Value
| Type | Description |
|---|---|
| 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 |
|---|---|
| bool |
Overrides
AnyResultHasError()
Returns true if any of the results had an error.
Declaration
protected override bool AnyResultHasError()
Returns
| Type | Description |
|---|---|
| bool |
Overrides
Complete()
Virtual method implemented by derived classes. Completes the request. Called when the request is older than allowed, forcing it to 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>, 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(ExecutionContext)
Starts executing all the queued callback functions in the given execution context.
Declaration
public void Execute(AsyncRequest.ExecutionContext executionContext = ExecutionContext.None)
Parameters
| Type | Name | Description |
|---|---|---|
| AsyncRequest.ExecutionContext | executionContext | Execution context in which the functions needs to be invoked. |
~AsyncRequest()
Declaration
protected ~AsyncRequest()
Reset()
Resets the request. Called when adding back to the object pool.
Declaration
public override void Reset()
Overrides
Start(Func<AsyncRequest<T>, Result>, 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 = 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
operator +(AsyncRequest<T>, Func<AsyncRequest<T>, 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. |