Class SimpleRetryPolicy<T>
- Namespace
- DotCompute.Backends.Metal.Utilities
- Assembly
- DotCompute.Backends.Metal.dll
Generic implementation of retry policy for Metal operations.
public sealed class SimpleRetryPolicy<T> : IAsyncPolicy<T>
Type Parameters
TThe return type.
- Inheritance
-
SimpleRetryPolicy<T>
- Implements
-
IAsyncPolicy<T>
- Inherited Members
Remarks
Initializes a new instance of the SimpleRetryPolicy<T> class.
Constructors
SimpleRetryPolicy(int, TimeSpan, ILogger?)
Generic implementation of retry policy for Metal operations.
public SimpleRetryPolicy(int maxRetries = 3, TimeSpan delay = default, ILogger? logger = null)
Parameters
maxRetriesintMaximum number of retries.
delayTimeSpanDelay between retries.
loggerILoggerLogger for diagnostics.
Remarks
Initializes a new instance of the SimpleRetryPolicy<T> class.
Methods
ExecuteAsync(Func<Task<T>>, CancellationToken)
Executes a function with retry logic.
public Task<T> ExecuteAsync(Func<Task<T>> operation, CancellationToken cancellationToken = default)
Parameters
operationFunc<Task<T>>The operation to execute.
cancellationTokenCancellationTokenCancellation token.
Returns
- Task<T>
A task representing the operation with a return value.