Table of Contents

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

TAccelerator

The type of accelerator this backend provides.

TOptions

The 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

string

ConfigurationSectionName

Gets the configuration section name for backend options. Override this to customize the configuration section path.

protected abstract string ConfigurationSectionName { get; }

Property Value

string

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

services IServiceCollection

The service collection.

configuration IConfiguration

The configuration instance.

ConfigureServices(IServiceCollection, IConfiguration)

Configures services for dependency injection.

public override void ConfigureServices(IServiceCollection services, IConfiguration configuration)

Parameters

services IServiceCollection

The service collection to configure.

configuration IConfiguration

The 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

name string

The name for the accelerator.

accelerator TAccelerator

The 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

cancellationToken CancellationToken

Cancellation 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

cancellationToken CancellationToken

Cancellation 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

cancellationToken CancellationToken

Cancellation 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

cancellationToken CancellationToken

Returns

Task

OnStartAsync(CancellationToken)

Provides common lifecycle logging for startup. Override OnStartAsync to add backend-specific startup logic.

protected override Task OnStartAsync(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

Returns

Task

OnStopAsync(CancellationToken)

Provides common lifecycle logging for shutdown. Override OnStopAsync to add backend-specific shutdown logic.

protected override Task OnStopAsync(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

Returns

Task

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

services IServiceCollection

The service collection.

configuration IConfiguration

The 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

services IServiceCollection

The service collection.