Class BaseBackendPlugin<TAccelerator, TOptions>
- Namespace
- DotCompute.Plugins.Core
- Assembly
- DotCompute.Plugins.dll
Abstract base class for backend plugins that provides common registration patterns. Uses the template method pattern to allow backend-specific customization while eliminating duplicate code across backend implementations.
public abstract class BaseBackendPlugin<TAccelerator, TOptions> : BackendPluginBase, IBackendPlugin, IDisposable where TAccelerator : class, IAccelerator where TOptions : class, new()
Type Parameters
TAcceleratorThe type of accelerator this backend provides.
TOptionsThe type of backend-specific configuration options.
- Inheritance
-
BaseBackendPlugin<TAccelerator, TOptions>
- Implements
- Derived
- Inherited Members
- Extension Methods
Properties
AcceleratorName
Gets the name used for the named accelerator wrapper. Override this to customize the accelerator name.
protected abstract string AcceleratorName { get; }
Property Value
ConfigurationSectionName
Gets the configuration section name for backend options. Override this to customize the configuration section path.
protected abstract string ConfigurationSectionName { get; }
Property Value
Methods
ConfigureBackendOptions(IServiceCollection, IConfiguration)
Configures backend-specific options. Override this method to provide custom configuration binding logic.
protected virtual void ConfigureBackendOptions(IServiceCollection services, IConfiguration configuration)
Parameters
servicesIServiceCollectionThe service collection.
configurationIConfigurationThe configuration instance.
ConfigureServices(IServiceCollection, IConfiguration)
Configures services for dependency injection.
public override void ConfigureServices(IServiceCollection services, IConfiguration configuration)
Parameters
servicesIServiceCollectionThe service collection to configure.
configurationIConfigurationThe configuration for the plugin.
CreateNamedAcceleratorWrapper(string, TAccelerator)
Creates a named accelerator wrapper. Override this method to provide custom wrapper implementation if needed.
protected virtual IAccelerator CreateNamedAcceleratorWrapper(string name, TAccelerator accelerator)
Parameters
namestringThe name for the accelerator.
acceleratorTAcceleratorThe underlying accelerator instance.
Returns
- IAccelerator
A wrapped accelerator with the specified name.
OnBackendInitializeAsync(CancellationToken)
Called during backend initialization. Override this method to add backend-specific initialization logic.
protected virtual Task OnBackendInitializeAsync(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationTokenCancellation token.
Returns
- Task
Task representing the async operation.
OnBackendStartAsync(CancellationToken)
Called during backend startup. Override this method to add backend-specific startup logic.
protected virtual Task OnBackendStartAsync(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationTokenCancellation token.
Returns
- Task
Task representing the async operation.
OnBackendStopAsync(CancellationToken)
Called during backend shutdown. Override this method to add backend-specific shutdown logic.
protected virtual Task OnBackendStopAsync(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationTokenCancellation token.
Returns
- Task
Task representing the async operation.
OnInitializeAsync(CancellationToken)
Provides common lifecycle logging for initialization. Override OnInitializeAsync to add backend-specific initialization logic.
protected override Task OnInitializeAsync(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationToken
Returns
OnStartAsync(CancellationToken)
Provides common lifecycle logging for startup. Override OnStartAsync to add backend-specific startup logic.
protected override Task OnStartAsync(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationToken
Returns
OnStopAsync(CancellationToken)
Provides common lifecycle logging for shutdown. Override OnStopAsync to add backend-specific shutdown logic.
protected override Task OnStopAsync(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationToken
Returns
RegisterAccelerator(IServiceCollection, IConfiguration)
Registers the backend-specific accelerator. This method must be implemented by derived classes to provide their specific accelerator registration logic.
protected abstract void RegisterAccelerator(IServiceCollection services, IConfiguration configuration)
Parameters
servicesIServiceCollectionThe service collection.
configurationIConfigurationThe configuration instance.
RegisterNamedAccelerator(IServiceCollection)
Registers the named accelerator wrapper that provides the common IAccelerator interface. Override this method if you need custom wrapper behavior.
protected virtual void RegisterNamedAccelerator(IServiceCollection services)
Parameters
servicesIServiceCollectionThe service collection.